The following second-order ODE is considered to be stiff: d2y/dx2=−1001dy/dx−1000?
initial conditions are: y(0)=1 and ?′(0)=0
What to solve the ODE using Euler’s method with implicit function.
I implemetd the above question using matlab. But implemented code gives this error.
I attached the code. Can anyone suggest me about the bug of this code?.
function dy = dpnon(t, y)dy = [y(2);-1000*y(1)-1001*y(2)];endfunction [x,y]=euler_explicit(f,xinit,yinit,xfinal,h)n=(xfinal-xinit)/h;% Initialization of x and y as column vectors
x=[xinit zeros(1,n)]; y=[yinit zeros(1,n)];% Calculation of x and y
for i=1:nx(i+1)=x(i)+h;y(i+1)=y(i)+h*f(x(i),y(i));endendxinit=0;xfinal=3;yinit=0;h=.5;euler_explicit(@dpnon,xinit,yinit,xfinal,h)
Best Answer