% Script for testing the Implicit Euler method for the heat equation u = @(x,t) (1+x).^3.*(1+t.^2); f = @(x,t) (1+x).^3*2.*t-6*(1+x).*(1+t.^2); g0 = @(t) 1+t.^2; g1 = @(t) 8*(1+t.^2); v = @(x) (1+x).^3; M=5; MT=10; for i=1:5 [U,X,T]=heatImplEuler(2,f,v,g0,g1,M,MT); Err = U - u(X,T); error(i)=max(abs(Err(:))); M=2*M; MT=4*MT; end