ASSINGNMENT NO.
Batch- T2
FLOWCHART FOR ORDINARY DIFFERENTIAL EQUATION BY
MODIFIED EULER’S METHOD
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
Enter the value of x0=0
Enter the value of y0=1
Enter the value of xn=0.1
Enter the desired accuracy=0.0001
The final value of yn=1.105580>>