Ordinary Differential Equations المعادلات التفاضلية العادية : شرح مبسط باللغة العربية 1. Initial Value Problems: 1.1. Euler's method. 1.2. Second-order Taylor method. The complete MATLAB SCRIPT: clc;clear all;close all % %Initial vaues: x0=0;y0=0.5; %Terminal value of x: xn=1; %The size step: h=0.1; %The number of subintervals is: n=(xn-x0)/h; %Introduce x values: x=x0:h:xn; %Function definition: f=@(x,y) ((exp(-x)-y)/2); %The derived of the function: df=@(x,y)((-3*exp(-x)+y)/4); %Initialise y for the loop: yEu(1)=y0; yT2(1)=y0; %Calculate y using Euler and Taylor2 methods: for i=1:n yEu(i+1)=yEu(i)+ h*f(x(i),yEu(i)); yT2(i+1)=yT2(i)+h*(f(x(i),yT2(i))+(1/2)*h*df(x(i),yT2(i))); end %Calculate the exact values: for i=1:n+1 yEx(i)=3/2*exp(-x(i)/2)-exp(-x(i)); end %Calculate the relative errors: for i=1:n+1 e_Eu(i) = (yEx(i)-yEu(i))/yEx(i)*100; e_T2(i) = (yEx(i)-yT2(i))/yEx(i)*100; end disp(' x |yEuler | yTaylor2| yexact |e_Euler |e_Taylor2') disp(' ------------------------------------------------------') fprintf('%7.2f |%7.4f | %7.4f |%7.4f | %4.2f | %4.2f \n',[x;yEu;yT2;yEx;e_Eu;e_T2])