% solution to the characteristic value problem format short e diary data_cvp; for n = 10:10:200 [A,h] = mesheig(n); [v,lambda] = eig(A); x = 0:h:1; m = max(v(:,1)); y = [0; v(:,1)/m; 0]; plot(x,y); hold on yy = sin(pi*x); plot(x,yy); err = max(abs(yy - y')); order = log(err)/log(h); printf("n = %3d h = %.2e err = %.2e order = %.2e\n",n,h,err,order); end; diary off;