This can be done fairly easy in maple. For this I have choose the pde from your other question because that pde has an exact solution.
restart:with(plots):
pde:= diff(u(x, t), t) = diff(u(x, t), x, x)-sin(x+t)+cos(x+t);
First we will check whether your exact solution satisfy the pde or not. For this
ansol:=u(x, t)=cos(x+t);
0
The zero output means that the exact solution satisfies the pde. Now moving on to the numerical solution,
ic:={u(x,0)=cos(x)};
bcs:={ D[1](u)(0,t)=-sin(t),D[1](u)(1,t)=-sin(1+t)};
pds:= pdsolve({pde},ic union bcs,numeric,time=t,range=0..1,errorest=true,timestep=1/16,spacestep=1/16);
In pdsolve
we have utilized the option errorest=true
to compute error estimates.
The error estimators used, in both the visual error estimates and the error control, are simply local truncation error estimates for the PDE or PDE system.
First, lets find out the effect of the timestep
and spacestep
on the error,
pds:-settings(timestep=1/8,spacestep=1/8);
pds:-plot([u(x,t),[u(x,t)+err(u(x,t)),color=blue,linestyle=2],[u(x,t)-err(u(x,t)),color=green,linestyle=3]],t=5,axes=boxed);

Now we reduce the timestep
and spacestep
pds:-settings(timestep=1/64,spacestep=1/64);
pds:-plot([u(x,t),[u(x,t)+err(u(x,t)),color=blue,linestyle=2],[u(x,t)-err(u(x,t)),color=green,linestyle=2]],t=5,axes=boxed);

Clearly, we can see from the above plot that the error in the pde solution is acceptable.
Now we will plot the error in the solution along the space

Plotting error in the solution with time,

Finally, visualizing the absolute error,
pds:-plot([[(abs(u(x,t)-(cos(x+t)))^2),color=red]],t=5,axes=boxed);

pds:-plot([[(abs(u(x,t)-(cos(x+t)))^2),color=red]],t=0..5,x=0.5,axes=boxed);
