Hi having some real trouble on this asignment would apprecia
Hi having some real trouble on this asignment, would appreciate any help for Exercise 3 and 4. Thank you in advance!
MAT275 LABo3 v2.pdf x CI Am Having Trouble Fi x der The IVP Y? x My ASU https://math la-asu-ed x Modify the M-file Secure h math,la asu.edu /LAB VIDEOS/LAB 3/MAT275 LAB03 v2.pdf Eli Apps L School L Clubs Netfl YouTube A Asoft Murmur Fall 2017 classes https://math-la. https://math laa MAT275 LAB03 v2.poi MAT275 LAB03 v2.pdf 3. Modify he M-file euler.m o implement the algorithm for Improved Euler. Call the new file inpeuler in nclude the file in your report Test your code for the ODE y 3y, y(0) 2. First enter the function f(t,y 3y as anonymous function and then enter the following: [t5,y5] impeuler (f 5],2,5); use or if defined in separate function 2.0000 0.1000 2.6900 0.2000 3.6181 0.3000 8663 0.4000 6.5451 0.5000 8.8032 Compare your output with the one above. Note that the improved Euler approximation with 5 steps is already more accurate than the Euler approximation with 50 steps! (hence the \"improved 4. Consider the IVP y\' 3y, y(0) 2 0 f S 0.5 (a) Determine the improved Euler\'s approximation for N 50, N 500 and N 5000. Fill in the following table with the values of the approximations, errors and ratios of consecutive errors at t 0.5. One of the values has already been entered based on the computations we did above. Recall that the exact solution to the ODE is y 2e Include the table in your report, as well as the MATLAB commands used to find the entries. ratio N approximation error 85012 So (b) Examine the last column. How does the ratio of the errors relate to the number of steps used? Your answer to this question should confirm the fact that Improved Euler\'s method is of order h2 that is, every time the steps is decreased by a factor k, the error is reduced (approximately) by a factor of k2. c, t ENG 35 PMSolution
function [g,er]=improvEuler(t,h)
y(1)=2;
%Improved Euler formula
for i=1:length(t)-1
m1=3*y(i);
m2=3*(y(i)+h*m1);
y(i+1)=y(i)+(h/2)*(m1+m2);
end
%Exact solution
for i=1:length(t)
y_ex(i)=2*exp(3*t(i));
end
%Error at t=0.5
g=y(length(t));
er=abs( y_ex(length(t))-y(length(t)));
end
Now we call this function in below
clc;
clear all;
N(1)=5;
N(2)=50;
N(3)=500;
N(4)=5000;
for i=1:4
h(i)=1/N(i);
t=0:h(i):0.5;
[g(i),er(i)]=improvEuler(t,h(i));
end
for i=1:3
ratio(i)=log(er(i)/er(i+1));
end
ratio(4)=0;
disp(\'At t=0.5\')
disp(\'---------------------------------------------\')
disp(\'N Approximation erorr ratio\')
disp(\'---------------------------------------------\')
for i=1:4
fprintf(\'%f\\t %f \\t %f\\t %f\ \',N(i),g(i),er(i), ratio(i))
end
At t=0.5
------------------------------------------------------------------
N Approximation erorr ratio
-------------------------------------------------------------------
5.000000 6.336800 0.303434 3.672722
50.000000 8.955669 0.007709 4.564329
500.000000 8.963298 0.000080 4.601116
5000.000000 8.963377 0.000001 0.000000
I did ration is error of N=50 at t=0.5 divieds N=5 at t=0.5

