@tomleslie , hi tom; I changed a little bit your code (the natural logs I changed to log10, tval changed to 5, and I am now looking at the error norm between cos(x+t) and the solution of the PDE:
diff(v(x, t), t) = diff(v(x, t), x, x)-sin(x+t)+cos(x+t)
the analytical solution of this PDE is cos(x+t))
Now in order to calculate the slope of the log10 log10 graph I use:
LeastSquares([[log10(1/16), log10(E)], [log10(1/32),log10(E)],[log10(1/64), log10(E)],[log10(1/128),log10(E)],[log10(1/256),log10(E)]], v);
I get a slope that is smaller than 2 while if I change the boundary conditions to:
(its analytical solution is also cos(x+t))
I get a slope which is approximately 2.
My colleague told me that theoretically the slope should be 2, why is that if I change to the first boundary conditions that the slope of the log log graph decreases so drastically?
The analytical solution of the two problems is identical, isn't it?
Thanks in advance, I appreciate your help.
Forgot to add that now we are comparing the numerical solutions of the PDEs with the analytical solution which in this case is cos(x+t).