
Display all methods listed below in ONE GRAPH:
1. Analytical method
2. Euler's method
3. Heun's method without iteration
4. Ralston's method
5. Fourth-order RK method
Metlab preferred




%%Matlab code for Euler, Mid Point, RK2 and RK4 method
clear all
close all
%Function for which solution have to do
f=@(t,y) (1+4.*t).*sqrt(y);
h=0.25; % amount of intervals
fprintf('\nSolution for Euler method using step
size %2.2f.\n',h)
fprintf('Initial condition y(0)=1 at
t=0.\n')
%Euler method
%%%%%%%%%%%%%%%
t=0;
% initial t
y=1;
% initial y
t_eval=1; % at what point
we have to evaluate
n=(t_eval-t)/h; % Number of steps
t2(1)=t;
y2(1)=y;
for i=1:n
%Eular Steps
m=double(f(t,y));
t=t+h;
y=y+h*m;
t2(i+1)=t;
y2(i+1)=y;
fprintf('\t at t=%2.2f
value of y(%2.2f)=%f\n',t2(i+1),t2(i+1),y2(i+1))
end
%Huen method
%%%%%%%%%%%%%%%
fprintf('\nSolution for Heun method using step
size %2.2f.\n',h)
fprintf('Initial condition y(0)=1 at
t=0.\n')
t=0;
% initial t
y=1;
% initial y
t_eval=1; % at what point
we have to evaluate
n=(t_eval-t)/h; % Number of steps
t3(1)=t;
y3(1)=y;
for i=1:n
%Huen steps
m1=double(f(t,y));
m2=double(f((t+h),(y+h*m1)));
y=y+double(h*((m1+m2)/2));
t=t+h;
y3(i+1)=y;
t3(i+1)=t;
fprintf('\t at t=%2.2f value
of y(%2.2f)=%f\n',t3(i+1),t3(i+1),y3(i+1))
end
%RK4 method
%%%%%%%%%%%%%%%
fprintf('\nSolution for RK4 method using step
size %2.2f.\n',h)
fprintf('Initial condition y(0)=1 at
t=0.\n')
t=0;
% initial t
y=1;
% initial y
t_eval=1; % at what point
we have to evaluate
n=(t_eval-t)/h; % Number of steps
t4(1)=t;
y4(1)=y;
for i=1:n
%RK4 Steps
k1=h*double(f(t,y));
k2=h*double(f((t+h/2),(y+k1/2)));
k3=h*double(f((t+h/2),(y+k2/2)));
k4=h*double(f((t+h),(y+k3)));
dx=(1/6)*(k1+2*k2+2*k3+k4);
t=t+h;
y=y+dx;
t4(i+1)=t;
y4(i+1)=y;
fprintf('\t at t=%2.2f value
of y(%2.2f)=%f\n',t4(i+1),t4(i+1),y4(i+1))
end
%Ralston method
%%%%%%%%%%%%%%%
fprintf('\nSolution for Ralston method using
step size %2.2f.\n',h)
fprintf('Initial condition y(0)=1 at
t=0.\n')
t=0;
% initial t
y=1;
% initial y
t_eval=1; % at what point
we have to evaluate
n=(t_eval-t)/h; % Number of steps
t5(1)=t;
y5(1)=y;
for i=1:n
%RK2 Steps
k1=h*double(f(t,y));
k2=h*double(f((t+h),(y+k1)));
dx=(1/2)*(k1+k2);
t=t+h;
y=y+dx;
t5(i+1)=t;
y5(i+1)=y;
fprintf('\t at t=%2.2f value
of y(%2.2f)=%f\n',t5(i+1),t5(i+1),y5(i+1))
end
%%Exact solution
syms y(t)
eqn = diff(y,t) ==
(1+4*t)*sqrt(y);
cond = y(0) == 1;
ySol(t) =
dsolve(eqn,cond);
fprintf('Exact solution
for given ode is y(t)=')
disp(ySol)
yy_ext(t)=(t*(2*t + 1) +
2)^2/4;
fprintf('Initial
condition y(0)=1 at t=0.\n')
for
ii=1:length(t4)
y6(ii)=double(yy_ext(t4(ii)));
fprintf('\t at t=%2.2f value of
y(%2.2f)=%f\n',t4(ii),t4(ii),y6(ii))
end
%%Plotting solution using Euler method
figure(1)
hold on
plot(t2,y2,'Linewidth',2)
plot(t3,y3,'Linewidth',2)
plot(t4,y4,'Linewidth',2)
plot(t5,y5,'linewidth',2)
plot(t4,y6,'linewidth',2)
xlabel('t')
ylabel('y(t)')
title('Solution plot y(t) vs. t')
legend('Euler Method','Heun Method','RK4 Method','Ralston
Method','Exact solution','Location','northwest')
grid on
%%%%%%%%%%%%%%%%% End of Code %%%%%%%%%%%%%%%
Display all methods listed below in ONE GRAPH: 1. Analytical method 2. Euler's method 3. Heun's method without iteration 4. Ralston's method 5. Fourth-order RK method Metlab preferred Sol...
I want Matlab code.
22.2 Solve the following problem over the interval from x = 0 to 1 using a step size of 0.25 where y(0)-1. Display all your results on the same graph. r dV = (1 + 4x) (a) Analytically. (b) Using Euler's method. (c) Using Heun's method without iteration. (d) Using Ralston's method. (e) Using the fourth-order RK method.
22.2 Solve the following problem over the interval from x = 0 to 1 using a step size...
show all step please ((NOT in MATLAB))
except part d
Ralston's method
22.2 Solve the following problem over the interval from x = 0 to 1 using a step size of 0.25 where y(0) = 1. Display all your results on the same graph. Bolo dy bolo moto = (1 + 2x)VÝ Viena no woliszt unigas og tog (a) Analytically. sanoi solist og (b) Using Euler's method. (c) Using Heun's method without iteration. (d) Using Ralston's method. (e) Using the...
Solve using MATLAB code
22.2 Solve the following problem over the interval from 0 to 1 using a step size of 0.25 where y(0) 1. Display all your results on the same graph. dy dx (a) Analytically (b) Using Euler's method. (c) Using Heun's method without iteration. (d) Using Ralston's method. (e) Using the fourth-order RK method. Note that using the midpoint method instead of Ralston's method in d). You can use my codes as reference.
Q2 Using Fourth-order RK method, solve the following initial value problem over the interval from t = 0 to 1. Take the initial condition of y(0) = 1 and a step size (h)=0.5. dy = f(t, y) = y t- 1.1 y dt
1.Solve the following problem over the interval from t 0 to 1 using a step size of 0.25 where y(0) . Display your results on the same graph. dy dt (1 +4t)vy (a) Euler's method. (b) Ralston's method.
1.Solve the following problem over the interval from t 0 to 1 using a step size of 0.25 where y(0) . Display your results on the same graph. dy dt (1 +4t)vy (a) Euler's method. (b) Ralston's method.
PROBLEMS 22.1 Solve the following initial value problem over the interval from 0to2 where yo) 1.Display all your results on the same graph. dy=vr2-1.ly dt (a) Analytically. (b) Using Euler's method with h 0.5 and 0.25. (c) Using the midpoint method with h 0.5 (d) Using the fourth-order RK method with h 0.5.
PROBLEMS 22.1 Solve the following initial value problem over the interval from 0to2 where yo) 1.Display all your results on the same graph. dy=vr2-1.ly dt (a) Analytically....
(20 pts) 4. Solve the differential equation dy = yt? - 1.17 dt over the time interval of [O, 1.5) with the step size of 0.5 and y(0=1. 1) Obtain the analytical result. 2) Use Euler's method. 3. Use Heun's method with iterating the corrector. Do two iterations in the corrector step.
I need the visual basic code that is supposed to be typed
through excel
o Solve the following initial value problems with your VBA code over the interval from t 0 to 2 where y(0)1. o Graph the results from each solution method on the same graph. Analytically Euler's method with h 0.5 and h 0.25 Huen's method with h 0.5 and h 0.25 Fourth-order RK with h 0.5
o Solve the following initial value problems with your VBA code...
Problem 3. Given the initial conditions, y(0) from t- 0 to 4: and y (0 0, solve the following initial-value problem d2 dt Obtain your solution with (a) Euler's method and (b) the fourth-order RK method. In both cases, use a step size of 0.1. Plot both solutions on the same graph along with the exact solution y- cos(3t). Note: show the hand calculations for t-0.1 and 0.2, for remaining work use the MATLAB files provided in the lectures
Problem...
Problem 2. Solve the following pair of ODEs over the interval from 0 to 0.4 using a step size of 0.1. The initial conditions are (0)-2 and (0) 4. Obtain your solution with (a) Euler's method and (b) the fourth-order RK method. Display your results as a plot. dy =-2y+Sze dt dz dt 2