Question: Show matlab code in this problem with given code. and results 1+ 4. Use both modified Euler's and Runge - Kutta Methods to find the

 Show matlab code in this problem with given code. and results

1+ 4. Use both modified Euler's and Runge - Kutta Methods to

find the solutions of the following equations. Use the initial conditions of

Show matlab code in this problem with given code. and results

1+ 4. Use both modified Euler's and Runge - Kutta Methods to find the solutions of the following equations. Use the initial conditions of y(0)=0. Print a table of the numerical results and plot the approximated solution y. Compare the approximated results with the analytic solutions (you can use MATLAB to find the analytical solution) (25 pts)). 1 y(t) = y = f ( tanga) %Modified Euler's Method clear all; clc; t = 0; y = 1; h = .1; N = 10; for n = 1:N tnp1 = t +h; yp = f_euler(t,y); ybarnp1 = y + h*yp; Z ybarnp1p = f_euler(tnp1, ybarnp1); y = y + (h/2)*(yp + ybarnp1p); Qe(n,:) = [n ty]; t = tnp1; end Qe Janni =ython I har = f ( trois grand baly 't y! nti %Function function ( Eul_val ] = f_euler( t,y) Eul_val = t*y; end %Runge-Ketta Method t = 0; y = 1; h = 0.1; N = 10; for n = 1:N k1 = h*RG(t,y); TRUTURE k2 = 1* RG(t+h/2,y +(1/2)*k1); k3 = h* RG(t+h/2,y +(1/2)*k2); k4 = h*RG(t+h/2,y + k3); y = y + (1/6)*(k1+2*k2+2*k3+k4); t=t+h Qrn,:) = [n ty]; end Qr %Function function ( RG_val ] = RG(ty) RG_Val = thy end %Analytical Solutions Y_1stD - 'Dy-y*t'; y_init = 'y(0) == 1'; Y_analytical = dsolve(y_1stD,y_init,'t') 1+ 4. Use both modified Euler's and Runge - Kutta Methods to find the solutions of the following equations. Use the initial conditions of y(0)=0. Print a table of the numerical results and plot the approximated solution y. Compare the approximated results with the analytic solutions (you can use MATLAB to find the analytical solution) (25 pts)). 1 y(t) = y = f ( tanga) %Modified Euler's Method clear all; clc; t = 0; y = 1; h = .1; N = 10; for n = 1:N tnp1 = t +h; yp = f_euler(t,y); ybarnp1 = y + h*yp; Z ybarnp1p = f_euler(tnp1, ybarnp1); y = y + (h/2)*(yp + ybarnp1p); Qe(n,:) = [n ty]; t = tnp1; end Qe Janni =ython I har = f ( trois grand baly 't y! nti %Function function ( Eul_val ] = f_euler( t,y) Eul_val = t*y; end %Runge-Ketta Method t = 0; y = 1; h = 0.1; N = 10; for n = 1:N k1 = h*RG(t,y); TRUTURE k2 = 1* RG(t+h/2,y +(1/2)*k1); k3 = h* RG(t+h/2,y +(1/2)*k2); k4 = h*RG(t+h/2,y + k3); y = y + (1/6)*(k1+2*k2+2*k3+k4); t=t+h Qrn,:) = [n ty]; end Qr %Function function ( RG_val ] = RG(ty) RG_Val = thy end %Analytical Solutions Y_1stD - 'Dy-y*t'; y_init = 'y(0) == 1'; Y_analytical = dsolve(y_1stD,y_init,'t')

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!