Boundary value problems 373
The exact solution now is easiest to write in the form
c=c1e−x+c2ex
The left boundary condition gives c1=1 while the boundary condition at infinity
gives c2=0.
The Matlab program for this problem is
1function s15h10p2
10 Lmax = 15;
11 [xLow,cLow] = solveBVP(dx,xmin,Lmin);
12 [xHigh,cHigh] = solveBVP(dx,xmin,Lmax);
13
14 %exact solution
25 saveas(h,‘s15h10p2 solution fig1.eps’,‘psc2’)
26
27 h = figure;
28 plot(xHigh,cHigh,‘ob’,xHigh,c exactHigh,‘-r’)
29 xlabel(‘$x$’,‘FontSize’,14)
40 legend boxoff
41 saveas(h,‘s15h10p2 solution fig3.eps’,‘psc2’)
42
43 %compute the error as a function of dx
44 nplot = 50;