You are on page 1of 3

5 part A

function bvp4 xlow = 0; xhigh = 1; S = [0,0;0,1]; options = bvpset('SingularTerm',S); guess = [1;1]; solinit = bvpinit(linspace(xlow,xhigh,10),guess); sol = bvp4c(@emdenode,@emdenbc,solinit,options); xint = linspace(xlow,xhigh); Sxint = deval(sol,xint); plot(xint,Sxint(1,:),'o',xint, xint.*(((1-3*besselk(1,1))/besseli(1,1)).*besseli(1,xint) + 3 .* besselk(1,xint)) -1 );

function dydx = emdenode(x,y) dydx = [ y(2) 1 + y(1) ]; function res = emdenbc(ya,yb) res = [ ya(1)-2 yb(1) ];

Accurate, but took multiple steps.

Part B
function bvp4 xlow = 0; xhigh = 1; solinit = bvpinit(linspace(xlow,xhigh,10),[1,-1]); sol = bvp4c(@bvp4ode,@bvp4bc,solinit); xint = linspace(xlow,xhigh); Sxint = deval(sol,xint); plot(xint,Sxint(1,:),'o',xint, xint .* (((1-3*besselk(1,1))/besseli(1,1)).*besseli(1,xint) + 3 .* besselk(1,xint))-1) function dydx = bvp4ode(x,y) dydx = [ y(2) (x+x*y(1)+y(2))/(e+x)];

function res = bvp4bc(ya,yb) res = [ya(1)-2 yb(1)];

E = 0.5

E=0.05 Similar to analytical.

E=0.005 Almost the same.

You might also like