clear all;
y(1)=8;
% analytical y= 4+(y(0)-4)*e-0.5t
t=0.01:0.01:5;
y1=4+(y(1)-4)*exp(-0.5*t);
% Eulers method y_n+1=y_n+h*f(t,y) with h=.5
h1=0.5;
t2=0:h1:5;
for n=2:length(t2)
y2(1)=y(1);
y2(n)=y2(n-1)+h1*(2-((y2(n-1))/2));
end
% Eulers method y_n+1=y_n+h*f(t,y) with h=.25
h2=0.25;
t3=0:h2:5;
for n=2:length(t3)
y3(1)=y(1);
y3(n)=y3(n-1)+h2*(2-((y3(n-1))/2));
end
%mid point method
h3=.5;
t4=0:.5*h3:5;
for n=2:length(t4)
y4(1)=y(1);
y4(n)=y4(n-1)+.5*h3*(2-((y3(n-1))/2));
end
% fourth-order RK method with h=.5
h5=0.5;
t5=0:h5:5;
for n=2:length(t5)
y5(1)=y(1);
K1=2-((y5(n-1))/2);
K2=2-((y5(n-1)+(K1*h5/2))/2);
K3=2-((y5(n-1)+(K2*h5/2))/2);
K4=2-((y5(n-1)+(K3*h5))/2);
m=(K1/6)+(K2/3)+(K3/3)+(K4/6);
y5(n)=y5(n-1)+m*h5;
end
plot(t,y1,t2,y2,t3,y3,'*y',t4,y4,'r',t5,y5,'*');grid on;
legend('analytical','Euler,h=0.5','Euler,h=0.25','midpoint,h=0.5','4th
order RK h=0.5')
SOLVE USING MATLAB Problem 22.1A. Solve the following initial value problem over the interval fromt 0...
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....
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.
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...
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...
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
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
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...
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.
Solve the following Initial value problem over the Interval from t-0 to 2 where yo)-1 using the following methods dy= yt2_ 1.1y 5. value 15.00 points Fourth-order RK method with h- 0.5 at t-2 O 0.5914 O 1.5845 O 2.7332 O 0.7614
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.