Question: THE APPLICATION USED FOR THIS QUESTION IS MATLAB. PLEASE HELP IN MODIFYING THE PROGRAM. Below is the given program: (euler_ode.m) Exercise (3) Download euler_ode.m and
THE APPLICATION USED FOR THIS QUESTION IS MATLAB. PLEASE HELP IN MODIFYING THE PROGRAM.

Below is the given program: (euler_ode.m)

Exercise (3) Download euler_ode.m and modify it to develop a script that will solve initial value problems using the Heun's method and Midpoint method. Solve the ODE and compare the results (percentage error) using the true solution. ODE:y' = 4e 0.8t - 0.5y = 0.80 4 True Solution: y = (ew.8t - e-0.5t) + 2e-0.5t 1.3 t = 0 to 4, initial condition at t=0, y=2, step size = 1. 1 2 3 4 min 000 Solves dy/dt = f(t,y) with initial condition y(a) = yo % on the interval [a,b] using n steps of Euler's method. % Inputs: % dy function that is to be solved using Euler's method % f true value of the function % x = = initial value (minimum) % final value (maximum) % initial condition when y() % h step size % Outputs: % display the initial and final values of x -- 'X' % y displays the results solved using Euler's method -- % f(x) displays the true values of the function xn-- 'y (Euler) -- 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 %Inputs: dy = @(x,y)x*y; f=@(x)exp(x^2/2); x0=0; xn=2; y=1; h=0.1; %function to be solved %true form of the function %initial value (minimum) %final value (maximum) %initial condition when y() %step size fprintf ("x \t\t y (Euler)\t y Analytical) ') fprintf ("%f \t $f\t %fin',x0,y,f(x0)); %creates a header for the resulting dataset Sformats the resulting dataset E %loop for the Euler's method for x = xo: h: xn-h y=y+dy(x,y)*h; x=x+h; fprintf ("%f \t 8F\t 3f ',x,y,f(x)); end
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
