%%%Matlab code
clc;
close all;
clear all;
f=@(x , y) (1+4*x)*sqrt(y);
y1(1)=1;
x(1)=0;
h=0.25;
t=0:h:1;
%%% Analytical method
[t1 y1]=ode45(f,[0 1],y1(1));
%%% Eular method
y2(1)=1;
for n=1:length(t)-1;
y2(n+1)=y2(n)+h*f(t(n),y2(n));
end
%%%% Hen's Method
y3(1)=1;
for n=1:length(t)-1
yp=h*f(t(n),y3(n));
y3(n+1)=y3(n)+h/2*(f(t(n),y3(n))+f(t(n),yp));
end
%%%% RK-Method
yr(1)=1;
for k=1:length(t)-1
k1=h*feval(f,t(k),yr(k));
k2=h*feval(f,t(k)+h/2,yr(k)+k1/2);
k3=h*feval(f,t(k)+h/2,yr(k)+k2/2);
k4=h*feval(f,t(k)+h,yr(k)+k3);
yr(k+1)=yr(k)+(k1+2*k2+2*k3+k4)/6;
end
%%% Ralstan method
yrl(1)=1;
for k=1:length(t)-1
k1=h*f(t(k),yrl(k));
k2= h*f(t(k) + 2 *h / 3, yrl(k) + 2* k1 / 3 );
yrl(k+1)=yrl(k)+1/4*(k1+3*k2);
end
figure;
plot(t1,y1);
hold on
plot(t,y2,'-*');
hold on
plot(t,y3,'-o');
hold on
plot(t,yr','-^')
hold on
plot(t,yrl);
grid on
legend('Exact solution','Eular method','Hen''s Method','RK-4
method','Ralston method');
xlabel('x');
ylabel('y');
OUTPUT:
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 whe...
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.
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...
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.
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 Solve the following initial value problem over the interval from t= 0 to 1 where y(O) = 1 using the following methods with a step size of 0.25 4) dt Solve the following initial value problem over the interval from t= 0 to 1 where y(O) = 1 using the following methods...
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....
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 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
SOLVE USING MATLAB Problem 22.1A. Solve the following initial value problem over the interval fromt 0 to 5 where y(0) 8. Display all your results on the same graph. dt The analytical solution is given by: y(0) - 4e-0.5t (a) Using the analytical solution. (b) Using Eulers 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.
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
solve it with matlab 25.24 Given the initial conditions, y(0) = 1 and y'(0) = 1 and y'(0) = 0, solve the following initial-value problem from t = 0 to 4: dy + 4y = 0 dt² Obtain your solutions with (a) Euler's method and (b) the fourth- order RK method. In both cases, use a step size of 0.125. Plot both solutions on the same graph along with the exact solution y = cos 2t.