Question

In: Advanced Math

1. Consider the initial value problem y′ =1+y/t, y(1)=3 for1≤t≤2. • Show that y(t) = t...

1. Consider the initial value problem y′ =1+y/t, y(1)=3 for1≤t≤2.

• Show that y(t) = t ln t + 3t is the solution to the initial value problem.

• Write a program that implements Euler’s method and the 4th order Runke-Kutta method for the above initial value problem. Use your program to solve with h = 0.1 for Euler’s and h = 0.2 for R-K.

• Include a printout of your code and a printout of the results at each time step.

• Use Taylor’s method to compute w1 with h = 0.1 for orders 1 through 4.

Solutions

Expert Solution

MATLAB Program for EULER METHOD h=0.1

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Solving ODE (IVP) using Euler method
clc; % Clears the screen
clear all;
format long   
h=0.1 % step size
t = 1:h:2;   
y(1) = 3; % initial condition
F_ty = @(t,y)(1+y/t); % Function f(t,y)

for n=1:(length(t)-1)
y(n+1)=y(n)+h*F_ty(t(n),y(n));
end
solution =[t' y'] % to disply all t and corresponding y values

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OUTPUT

solution =

1.000000000000000 3.000000000000000
1.100000000000000 3.400000000000000
1.200000000000000 3.809090909090909
1.300000000000000 4.226515151515152
1.400000000000000 4.651631701631701
1.500000000000000 5.083891108891109
1.600000000000000 5.522817182817183
1.700000000000000 5.967993256743257
1.800000000000000 6.419051683610507
1.900000000000000 6.875665666033314
2.000000000000000 7.337542806350856

MATLAB Program for ​​​​​​ RK METHOD h=0.2

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Runge-Kutta 4th order method
clear all
format short
clc;

f=@(t,y)(1+y/t); % y'=f(t,y)
y(1)=3; % index has been taken as i instead of 0

h=0.2;
a=1;b=2; % Range of t a<=t<=b
t=a:h:b;
N=(b-a)/h;

for n=1:(length(t)-1)
k1 = h*f(t(n),y(n));
k2 = h*f(t(n)+0.5*h,y(n)+0.5*k1);
k3 = h*f((t(n)+0.5*h),(y(n)+0.5*k2));
k4 = h*f((t(n)+h),(y(n)+k3));
  
y(n+1) = y(n) + (1/6)*(k1+2*k2+2*k3+k4) ;
end
solution =[t' y'] % to disply all t and corresponding y values

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

OUTPUT

solution =

1.0000 3.0000
1.2000 3.8188
1.4000 4.6710
1.6000 5.5520
1.8000 6.4580
2.0000 7.3863


Related Solutions

Consider the following initial value problem dy/dt = 3 − 2*t − 0.5*y, y (0) =...
Consider the following initial value problem dy/dt = 3 − 2*t − 0.5*y, y (0) = 1 We would like to find an approximation solution with the step size h = 0.05. What is the approximation of y(0.1)?
1. solve the initial value problem. (t^(2)+1)y'+2ty=tant , y(0)=2 2.find the solution to this initial value...
1. solve the initial value problem. (t^(2)+1)y'+2ty=tant , y(0)=2 2.find the solution to this initial value problem. yy'=e^x+x , y(0)=y_0 y_0 is a nonzero constant.
Solve the initial value problem: Y''-4y'+4y=f(t) y(0)=-2, y'(0)=1 where f(t) { t if 0<=t<3 , t+2...
Solve the initial value problem: Y''-4y'+4y=f(t) y(0)=-2, y'(0)=1 where f(t) { t if 0<=t<3 , t+2 if t>=3 }
Consider the initial value problem: y0 = 3 + x−y, y(0) = 1 (a) Solve it...
Consider the initial value problem: y0 = 3 + x−y, y(0) = 1 (a) Solve it analytically. (b) Solve it using Euler’s method using step size h = 0.1 and find an approximation to true solution at x = 0.3. (c) What is the error in the Euler’s method at x = 0.3
Consider the following initial value problem: ?? − 2?? = √? − 2? + 3 ??...
Consider the following initial value problem: ?? − 2?? = √? − 2? + 3 ?? ?(0) = 6 1. Write the equation in the form ?? ?? = ?(?? + ?? + ? ), where ?, ?, ??? ? are constants and ? is a function. 2. Use the substitution ? = ?? + ?? + ? to transfer the equation into the variables ? and ? only. 3. Solve the equation in (2). 4. Re-substitute ? = ??...
Consider the initial value problem y′ = 18x − 3y, y(0) = 2 (a) Solve it...
Consider the initial value problem y′ = 18x − 3y, y(0) = 2 (a) Solve it as a linear 1st order ODE with the method of the integrating factor. (b) Solve it using a substitution method. (c) Solve it using the Laplace transform.
Solve the initial value problem. (x^2 * D^2 +xD - 4i) * y = x^3, y(1)...
Solve the initial value problem. (x^2 * D^2 +xD - 4i) * y = x^3, y(1) = -4/5, y'(1) = 93/5
Solve the initial value problem. y'=(y^2)+(2xy)+(x^2)-(1), y(0)=1
Solve the initial value problem. y'=(y^2)+(2xy)+(x^2)-(1), y(0)=1
Find the solution to the following initial value problem y' -y = t - sint +...
Find the solution to the following initial value problem y' -y = t - sint + e^(2t); y(0) = 0
Solve the initial value problem: y'' + y = cos(x) y(0) = 2 y'(0) = -3...
Solve the initial value problem: y'' + y = cos(x) y(0) = 2 y'(0) = -3 y' being the first derivative of y(x), y'' being the second derivative, etc.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT