Code covered by the BSD License

# Euler’s method

### Mohammed Al-Mostafa (view profile)

find the function then draw it using the derivative Euler’s method

Euler
```function Euler
fprintf('Created By Mohammed Kayed');
pause
clc
clear
syms x y;
f(x,y)=input('Y''=');
func=char(f(x,y));
X0=input('X0=');
Y0=input('Y0=');
h=input('step size =');
fprintf('\nIf you want to choose the number of iteration press 1 \n');
fprintf('If you want to find the solution at some point press 2 \n');
if n==1
n=input('the # of iteration =');
clc
fprintf('Y''=%s \t Step size = %g \t # of iteration = %g\n',func,h,n);
disp('---------------------------------------------')
fprintf('\n\n# of iteration \t\t Xn \t\t\t Yn\n');
Q=zeros(1,n+1);
W=zeros(1,n+1);
for i=0:n
Q(1,i+1)=X0;
W(1,i+1)=Y0;
fprintf('\t\t %5g \t\t\t %+f \t\t %+f \n',i,X0,Y0);
Y0=double(Y0+h*f(X0,Y0));
X0=X0+h;
end
plot(Q,W);
else
n=input('The value of X you want to stop at =');
Q=zeros(1,n+1);
W=zeros(1,n+1);
clc
fprintf('Y''=%s \t Step size = %g \t # of iteration = %g\n',func,h,(n-X0)/h+1);
disp('---------------------------------------------')
fprintf('\n\n# of iteration \t\t\t  Xn \t\t\t\t   Yn\n');
i=0;
while 1
Q(1,i+1)=X0;
W(1,i+1)=Y0;
fprintf('\t\t%2g  \t\t\t %+f  \t\t %+f \n',i,X0,Y0);
if X0>=n
break
end
Y0=double(Y0+h*f(X0,Y0));
X0=X0+h;
i=i+1;
end
plot(Q,W);
end```