Question

In: Advanced Math

Please solve all parts Consider the following IVP y′ = 2t − y + 1, y(0)...

Please solve all parts

Consider the following IVP

y′ = 2t − y + 1, y(0) = 1.

Find an approximation of y(1) using

(a) the Euler’s method with N = 4,

(b) the Euler’s method with N = 8,

(c) the improved Euler’s method with N = 4,

(d) the improved Euler’s method with N = 8.

Solve the IVP, find y(1), and compare the accuracy |y(1)−yN | of the approximations.

Solutions

Expert Solution

Approximating y(1) using two methods with 4 different n values will take much time by hand. So I am providing MATLAB CODE for the same with all output.

part a

%%%%%%%%%%%% MATLAB CODE %%%%%%%%%%

% Euler Method
clear all
clc;
format short
f=@(t,y)(2*t-y+1); % dy/dt=f(t,y)=y-t^2
n=4;
a=0;
b=1;
h=(b-a)/n;
t = a:h:b;
y = zeros(1,length(t));
y(1)=1; % index has been taken as i instead of 0

for n=1:(length(t)-1)
y(n+1) = y(n)+h*f(t(n),y(n));
end
t_y=[t' y'] % Solution of ODE at t=0 to 1
yN=y(n+1) % Solution by Euler method
y1=1.7358 % Analytical solution
Accuracy=abs(y1-yN)

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

OUTPUT


t_y =

0 1.0000
0.2500 1.0000
0.5000 1.1250
0.7500 1.3438
1.0000 1.6328


yN = 1.6328

y1 = 1.7358
Accuracy = 0.1030

Part (b)

%%%%%%%%%%%%%%% MATLAB CODE %%%%%%%%%%%%%%%%%

% Euler Method
clear all
clc;
format short
f=@(t,y)(2*t-y+1); % dy/dt=f(t,y)=y-t^2
n=8;
a=0;
b=1;
h=(b-a)/n;
t = a:h:b;
y = zeros(1,length(t));
y(1)=1; % index has been taken as i instead of 0

for n=1:(length(t)-1)
y(n+1) = y(n)+h*f(t(n),y(n));
end
t_y=[t' y'] % Solution of ODE at t=0 to 1
yN=y(n+1) % Solution by Euler method
y1=1.7358 % Analytical solution
Accuracy=abs(y1-yN)

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

OUTPUT


t_y =

0 1.0000
0.1250 1.0000
0.2500 1.0313
0.3750 1.0898
0.5000 1.1724
0.6250 1.2758
0.7500 1.3976
0.8750 1.5354
1.0000 1.6872


yN = 1.6872
y1 = 1.7358
Accuracy = 0.0486

Part (c)

%%%%%%%%%%%%%%%%%%%%%%%% MATLAB CODE %%%%%%%%%

% Modified (Improved) Euler method
clear all
clc;
format short
f=@(t,y)(2*t-y+1); % dy/dt=f(t,y)=y-t^2
n=4;
a=0;
b=1;
h=(b-a)/n;
t = a:h:b;
y = zeros(1,length(t));
y(1)=1; % index has been taken as i instead of 0

for n=1:(length(t)-1)
y(n+1) = y(n)+h*f(t(n)+0.5*h,y(n)+0.5*h*f(t(n),y(n)));
end
t_y=[t' y'] % Solution of ODE at t=0 to 1
yN=y(n+1) % Solution by Modified Euler method
y1=1.7358 % Analytical solution
Accuracy=abs(y1-yN)

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

OUTPUT


t_y =

0 1.0000
0.2500 1.0625
0.5000 1.2207
0.7500 1.4537
1.0000 1.7451


yN = 1.7451
y1 = 1.7358
Accuracy = 0.0093

Part(d)

%%%%%%%%%%%%%%% MATLAB CODE

% Improved Euler Method
clear all
clc;
format short
f=@(t,y)(2*t-y+1); % dy/dt=f(t,y)=y-t^2
n=8;
a=0;
b=1;
h=(b-a)/n;
t = a:h:b;
y = zeros(1,length(t));
y(1)=1; % index has been taken as i instead of 0

for n=1:(length(t)-1)
y(n+1) = y(n)+h*f(t(n)+0.5*h,y(n)+0.5*h*f(t(n),y(n)));
end
t_y=[t' y'] % Solution of ODE at t=0 to 1
yN=y(n+1) % Solution by Euler method
y1=1.7358 % Analytical solution
Accuracy=abs(y1-yN)

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

OUTPUT


t_y =

0 1.0000
0.1250 1.0156
0.2500 1.0587
0.3750 1.1261
0.5000 1.2148
0.6250 1.3224
0.7500 1.4468
0.8750 1.5858
1.0000 1.7379


yN = 1.7379
y1 = 1.7358
Accuracy = 0.0021


Related Solutions

Use laplace transform to solve IVP 2y”+3y’+y=8e^(-2t) , y(0)=-4 , y’(0)=2
Use laplace transform to solve IVP 2y”+3y’+y=8e^(-2t) , y(0)=-4 , y’(0)=2
a) Solve IVP: y" + y' -2y = x + sin2x; y(0) = 1, y'(0) = 0
  a) Solve IVP: y" + y' -2y = x + sin2x; y(0) = 1, y'(0) = 0 b) Solve using variation of parameters: y" -9y = x/e^3x
1. solve the IVP: xy''-y/x=lnx, on (0, inifnity), y(1)=-1, y'(1)=-2 2.solve the IVP: y''-y=(e^x)/sqrtx, y(1)=e, y'(1)=0...
1. solve the IVP: xy''-y/x=lnx, on (0, inifnity), y(1)=-1, y'(1)=-2 2.solve the IVP: y''-y=(e^x)/sqrtx, y(1)=e, y'(1)=0 3. Given that y1(x)=x is a solution of xy''-xy'+y=0 on (0, inifinity, solve the IVP: xy''-xy'+y=2 on(0,infinity), y(3)=2, y'(3)=1 14. solve the IVP: X'=( 1 2 3) X, X(0)=(0 ##################0 1 4####### -3/8 ##################0 0 1 ########1/4
Solve the IVP: y’’’ – y ’= 2sinx where: y(0)=0, y’(0)=0, y”(0)=1 Use an annihilator method,...
Solve the IVP: y’’’ – y ’= 2sinx where: y(0)=0, y’(0)=0, y”(0)=1 Use an annihilator method, please.
Find the general solution and solve the IVP y''+y'-y=0, y(0)=2, y'(0)=0
Find the general solution and solve the IVP y''+y'-y=0, y(0)=2, y'(0)=0
using the Laplace transform solve the IVP y'' +4y= 3sin(t) y(0) =1 , y'(0) = -...
using the Laplace transform solve the IVP y'' +4y= 3sin(t) y(0) =1 , y'(0) = - 1 , i am stuck on the partial fraction decomposition step. please explain the decomposition clearly.
SOLVE the IVP: (D^2+1)y = e^t, y(0) = -1 and y'(0) = 1. Thank you.
SOLVE the IVP: (D^2+1)y = e^t, y(0) = -1 and y'(0) = 1. Thank you.
apply picard iteration to ivp y’=2y^2, y(0)=1 and solve the solution apply picard iteration to ivp...
apply picard iteration to ivp y’=2y^2, y(0)=1 and solve the solution apply picard iteration to ivp y’=2y^1/2, y(1)=0 and solve the solution
1) . Solve the IVP: y^''+6y^'+5y=0, y(0)=1, y^' (0)=3 2. Find the general solution to each...
1) . Solve the IVP: y^''+6y^'+5y=0, y(0)=1, y^' (0)=3 2. Find the general solution to each of the following: a) y^''+2y^'+5y=e^2x b) y^''+2x/(x^2+1) y'=x c) y^''+4y=1/(sin⁡(2x)) (use variation of parameters)
Please draw the solution without solve the IVP y"+y=dirac function (t-pi/2) y(0)=0, y'(0) . (Label y(t)...
Please draw the solution without solve the IVP y"+y=dirac function (t-pi/2) y(0)=0, y'(0) . (Label y(t) and t number as well) I need a professional expert to answer this question. (be able to follow the comment) (Show the step for what you need to get for drawing this solution as well)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT