Professional Documents
Culture Documents
Modifiedeulersmethod
Modifiedeulersmethod
Batch- T2
f=inline('(x*x+y)');
x0=input('Enter the value of x0=');
y0=input('Enter the value of y0=');
xn=input('Enter the value of xn=');
acc=input('Enter the desired accuracy=');
n=2;
h=((xn-x0)/n);
for i=1:n
y1=y0+h*f(x0,y0);
y11=y0+(h/2)*(f(x0,y0)+f((x0+h),y1));
while(abs(y11-y1)>acc)
y1=y11;
y11=y0+(h/2)*(f(x0,y0)+f((x0+h),y1));
end
x0=x0+h;
y0=y11;
end
fprintf('The final value of yn=%f',y11);
PROGRAM OUTPUT