Numerical Methods for Engineers
Numerical Methods for Engineers
7th Edition
ISBN: 9780073397924
Author: Steven C. Chapra Dr., Raymond P. Canale
Publisher: McGraw-Hill Education
bartleby

Concept explainers

bartleby

Videos

Textbook Question
Book Icon
Chapter 25, Problem 2P

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.

d y d t = ( 1 + 4 t ) y

(a) Analytically.

(b) Euler's method.

(c) Heun's method without iteration.

(d) Ralston's method.

(e) Fourth-order RK method.

(a)

Expert Solution
Check Mark
To determine

To calculate: The solution of the initial value problem dydt=(1+4t)y with initial condition as y(0)=1, analytically.

Answer to Problem 2P

Solution: The solution to the initial value problem is y(t)=(2t2+t+22)2.

Explanation of Solution

Given Information:

The initial value problem dydt=(1+4t)y with y(0)=1.

Formula used:

To solvean initial value problem of the form dydx=g(x)h(y) integrate both sides of the following equation:

dyh(y)=g(x)dx

Calculation:

Rewrite the provided differential equation as,

dydt=(1+4t)ydyy=(1+4t)dt

Integrate both sides to get,

2y12=t+2t2+Cy(t)=(t+2t2+C2)2

Now use the initial condition y(0)=1 to get the value of the constant C.

y(0)=(0+2(0)2+C2)21=C24C=2

Hence, the analytical solution of the initial value problem is y(t)=(t+2t2+22)2.

(b)

Expert Solution
Check Mark
To determine

To calculate: The solution of the initial value problem dydt=(1+4t)y with initial condition as y(0)=1 in the interval t(0,1) and the step-size of 0.25 using the Euler’s method.

Answer to Problem 2P

Solution: For h=0.25 the values are,

t y
0 1
0.25 1.25
0.5 1.809017
0.75 2.817765
1 4.496385

Explanation of Solution

Given Information:

The initial value problem dydt=(1+4t)y, with y(0)=1 in the interval t(0,1) with step-size 0.25.

Formula used:

Solvean initial value problem of the form dydx=f(xi,yi) using the iterative Euler method as,

yi+1=yi+f(xi,yi)h

Calculation:

From the initial condition y(0)=1, y0=1,t0=0.

Thus, evaluate the function f(t0,y0) as,

f(1,0)=(1+4(0))1=1

Further,

y1=y0+f(y0,t0)hy(0.25)=y(0)+f(1,0)0.25=1+1(0.25)=1.25

Proceed further and use the following MATLAB code to implement Euler’s method and solve the differential equation.

% Q 2 (b) Euler's Method when h=0.25

clear;clc;

% Define the end-points of the interval [0,2]

a=0;b=1;

% Define the initial condition y(0)=1

y1(1)=1;

t1(1)=a;

dydt1(1)=1;

% Mention the step-size as 0.25

h1=0.25;

% Compute the value of the number of iterations corresponding to the step-size;

n1=(b-a)/h1;

% Start the loop for the Euler's method

fori=1:n1

% Compute the value of the function to the right of the

% differential equation

dydt1(i+1)=(1+4*t1(i))*sqrt(y1(i));

% Compute the value of the variable y

y1(i+1)=y1(i)+h1*dydt1(i+1);

% Compute the value of the variable t

t1(i+1)=t1(i)+h1;

end

A1=[t1;y1]'

Execute the above code to obtain the solutions stored in matrix A1 as,

A1 =

0 1.0000

0.2500 1.2500

0.5000 1.8090

0.7500 2.8178

1.0000 4.4964

The results thus obtained are tabulated as,

T y
0 1
0.25 1.25
0.5 1.809017
0.75 2.817765
1 4.496385

(c)

Expert Solution
Check Mark
To determine

To calculate: The solution of the initial value problem dydt=(1+4t)y with initial condition as y(0)=1 in the interval t(0,1) with step-size 0.25 using the Heun’s methodwithout iteration.

Answer to Problem 2P

Solution: The solutions are tabulated as,

tyk1k20111.250.251.4045082.3702394.239530.52.37034.4806887.3221870.753.7060897.7048211.8650816.15178512.401418.52039

Explanation of Solution

Given Information:

The initial value problem dydt=(1+4t)y, with y(0)=1 in the interval t(0,1) with step-size of 0.25.

Formula used:

Solve an initial value problem of the form dydx=f(xi,yi) using the Heun’s method without iteration as,

yi+1=yi+(k1+k22)h

In the above expression,

k1=f(ki,yi)k2=f(xi+h,yi+k1h)

Calculation:

From the initial condition y(0)=1, y0=1,t0=0.

Thus, evaluate the function f(t0,y0) as,

k1=f(1,0)=(1+4(0))1=1

And,

k2=f(t0+0.25,y0+1(0.25))=f(0.25,1.25)=2.236068

Thus,

y1=y0+(k1+k22)h=1+(1+2.2360682)0.25=1.404508

Proceed further and use the following MATLAB code to implement Heun’s method and solve the differential equation.

% ———————————–

% Q 2 (c) Heun's Method when h=0.25

% Define the end-points of the interval [0,2]

a=0;b=1;

% Define the initial condition y(0)=1

y2(1)=1;

t2(1)=a;

dydt2(1)=1;

% Mention the step-size as 0.25

h2=0.25;

% Compute the value of the number of iterations corresponding to the step-size;

n2=(b-a)/h2;

% Start the loop for the Heun's method

fori = 1:n2+1

k21(i) = (1+4*t2(i))*sqrt(y2(i));

k22(i) = (1+4*(t2(i)+h2))*sqrt(y2(i)+k21(i)*h2);

y2(i+1) = y2(i) + 0.5*h2*(k21(i)+k22(i));

t2(i+1) = t2(i) + h2;

end

t2(:, end:end)=[];

y2(:, end:end)=[];

A2=[t2; y2; k21; k22]'

Execute the above code to obtain the solutions stored in matrix A2 as,

A2 =

0 1.0000 1.0000 2.2361

0.2500 1.4045 2.3702 4.2395

0.5000 2.2307 4.4807 7.3222

0.7500 3.7061 7.7005 11.8651

1.0000 6.1518 12.4014 18.2504

Theresults thus obtained aretabulated as,

tyk1k20111.250.251.4045082.3702394.239530.52.37034.4806887.3221870.753.7060897.7048211.8650816.15178512.401418.25039

(d)

Expert Solution
Check Mark
To determine

To calculate: The solution of the initial value problem dydt=(1+4t)y with y(0)=1 in the interval t(0,1) with step-size 0.25 using the Ralston’s method without iteration.

Answer to Problem 2P

Solution: The solutions are tabulated as,

tyk1k20111.9070180.251.401172.367423.7354080.52.2210234.4709296.5590940.753.6867837.68039810.7552216.11935212.3686616.70321

Explanation of Solution

Given Information:

The initial value problem dydt=(1+4t)y, with y(0)=1 in the interval t(0,1) and with the step-size of 0.25.

Formula used:

Solve an initial value problem of the form dydx=f(xi,yi) using the Ralston’s method without iteration as,

yi+1=yi+(k1+2k23)h

In the above expression,

k1=f(ki,yi)k2=f(xi+34h,yi+34k1h)

Calculation:

From the initial condition y(0)=1, y0=1,t0=0.

Thus, evaluate the function f(t0,y0) as,

k1=f(1,0)=(1+4(0))1=1

And,

k2=f(t0+34(0.25),y0+34(1)(0.25))=f(0.1875,1.1875)=1.907078

Thus,

y1=y0+(k1+2k23)h=1+(1+2(1.907018)3)0.25=1.40117

Proceed further and use the following MATLAB code to implement Ralston’s method and solve the differential equation.

% —————————————–

% Q 2 (d) Ralston's Method when h=0.25

% Define the end-points of the interval [0,2]

a=0;b=1;

% Define the initial condition y(0)=1

y3(1)=1;

t3(1)=a;

dydt3(1)=1;

% Mention the step-size as =0.25

h3=0.25;

% Compute the value of the number of iterations corresponding to the step-size;

n3=(b-a)/h3;

% Start the loop for the Heun's method

fori = 1:n3+1

k31(i) = (1+4*t3(i))*sqrt(y3(i));

k32(i) = (1+4*(t3(i)+0.75*h3))*sqrt(y3(i)+k31(i)*0.75*h3);

y3(i+1) = y3(i) + (1/3)*h3*(k31(i)+2*k32(i));

t3(i+1) = t3(i) + h3;

end

t3(:, end:end)=[];

y3(:, end:end)=[];

A3=[t3; y3; k31; k32]'

Execute the above code to obtain the solutions stored in matrix A3 as,

A3 =

0 1.0000 1.0000 1.9070

0.2500 1.4012 2.3674 3.7354

0.5000 2.2210 4.4709 6.5591

0.7500 3.6868 7.6804 10.7552

1.0000 6.1194 12.3687 16.7032

The results thus obtained are tabulated as,

tyk1k20111.9070180.251.401172.367423.7354080.52.2210234.4709296.5590940.753.6867837.68039810.7552216.11935212.3686616.70321

(e)

Expert Solution
Check Mark
To determine

To calculate: The solution of the initial value problem dydt=(1+4t)y with y(0)=1 in the interval t(0,1) with step-size 0.25 using the RK method of order four.

Answer to Problem 2P

Solution: The solutions are tabulated as,

tyk1k2k3k40111.590991.6423962.3753730.251.4100892.3749443.2662643.3711764.5028830.52.2497864.4997865.8694276.0454477.7574710.753.7534117.7494899.77867410.0978712.5128716.24905412.4990515.3719215.7212919.14308

Explanation of Solution

Given Information:

The initial value problem dydt=(1+4t)y, with y(0)=1 in the interval t(0,1) and with the step-size of 0.25.

Formula used:

Solve an initial value problem of the form dydx=f(xi,yi) using the iterative fourth order RK method as,

yi+1=yi+16(k1+2k2+2k3+k4)h

In the above expression,

k1=f(xi,yi)k2=f(xi+h2,yi+h2k1)k3=f(xi+h2,yi+h2k2)k4=f(xi+h,yi+k3h)

Calculation:

From the initial condition y(0)=1, y0=1,t0=0, thus,

k1=f(1,0)=(1+4(0))1=1

Ans,

k2=f(t0+0.252,y0+(0.252)k1)=f(0.25,1.125)=1.59099

And,

k3=f(t0+0.252,y0+(0.252)k2)=f(0.25,1.198874)=1.642396

And,

k4=f(t0+0.25,y0+0.25k3)=f(0.5,1.410599)=2.375373

Therefore,

y1=y0+16(k1+2k2+2k3+k4)(0.25)=1+16(1+2(1.59099)+2(1.642396)+(2.375373))(0.25)=1.410089

Proceed further and use the following MATLAB code to implement RK method of order four, solve the differential equation, and compare the results obtained from part (a) to part (e) on a single plot.

% % ————————————————–

% Q 2 (e) RK 4 Method when h=0.25

% Define the end-points of the interval [0,2]

a=0;b=1;

% Define the initial condition y(0)=1

y4(1)=1;

t4(1)=a;

% Mention the step-size as 0.25

h4=0.25;

% Compute the value of the number of iterations corresponding to the step-size;

n4=(b-a)/h4;

halfh = h4 / 2;

h6 = h4/6;

% Start the process

fori = 1: n4+1

t4(i+1) = t4(i) + h4;

% The values usually defined as k1, k2, k3 and k4

s41(i) = (1+4*t4(i))*sqrt(y4(i));

s42(i) = (1+4*(t4(i)+halfh))*sqrt(y4(i)+halfh*s41(i));

s43(i) = (1+4*(t4(i)+halfh))*sqrt(y4(i)+halfh*s42(i));

s44(i) = (1+4*(t4(i)+h4))*sqrt(y4(i)+h4*s43(i));

% The formula for the RK method of order 4

y4(i+1,:) = y4(i,:) + (s41(i) + s42(i)+s42(i) + s43(i)+s43(i) + s44(i)) * h6;

end;

t4(:, end:end)=[];

y4(end:end,:)=[];

% Display the values

A4=[t4' y4 s41' s42' s43' s44']

% Now plot the graphs for all the parts:

time=linspace(0,2);

exactsol=(time.^2+0.5*time+1).^2;

plot(time, exactsol)

xlabel('t')

axis([0 1.25 0 7])

hold on

plot(A1(:,1), A1(:,2));

hold on

plot(A2(:,1), A2(:,2));

hold on

plot(A3(:,1), A3(:,2));

hold on

plot(A4(:,1), A4(:,2));

hold on

legend('y(t)','Euler','Heun','Ralston','RK-4')

Execute the above code to obtain the solutions stored in matrix A4 as,

A4 =

0 1.0000 1.0000 1.5910 1.6424 2.3754

0.2500 1.4101 2.3749 3.2663 3.3712 4.5029

0.5000 2.2498 4.4998 5.8694 6.0454 7.7575

0.7500 3.7534 7.7495 9.7787 10.0379 12.5129

1.0000 6.2491 12.4991 15.3719 15.7213 19.1431

The results thus obtained are tabulated as,

tyk1k2k3k40111.590991.6423962.3753730.251.4100892.3749443.2662643.3711764.5028830.52.2497864.4997865.8694276.0454477.7574710.753.7534117.7494899.77867410.0978712.5128716.24905412.4990515.3719215.7212919.14308

Plot for all the methods along with the analytical solution y(t)=(2t2+t+22)2 is,

Numerical Methods for Engineers, Chapter 25, Problem 2P

From the graph, it is inferred that the RK method of order 4 is the best approximation to the solution.

Want to see more full solutions like this?

Subscribe now to access step-by-step solutions to millions of textbook problems written by subject matter experts!

Chapter 25 Solutions

Numerical Methods for Engineers

Knowledge Booster
Background pattern image
Advanced Math
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, advanced-math and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Text book image
Algebra & Trigonometry with Analytic Geometry
Algebra
ISBN:9781133382119
Author:Swokowski
Publisher:Cengage
Text book image
Trigonometry (MindTap Course List)
Trigonometry
ISBN:9781337278461
Author:Ron Larson
Publisher:Cengage Learning
Text book image
College Algebra
Algebra
ISBN:9781337282291
Author:Ron Larson
Publisher:Cengage Learning
Text book image
College Algebra
Algebra
ISBN:9781938168383
Author:Jay Abramson
Publisher:OpenStax
Text book image
Functions and Change: A Modeling Approach to Coll...
Algebra
ISBN:9781337111348
Author:Bruce Crauder, Benny Evans, Alan Noell
Publisher:Cengage Learning
Text book image
Algebra and Trigonometry (MindTap Course List)
Algebra
ISBN:9781305071742
Author:James Stewart, Lothar Redlin, Saleem Watson
Publisher:Cengage Learning
01 - What Is A Differential Equation in Calculus? Learn to Solve Ordinary Differential Equations.; Author: Math and Science;https://www.youtube.com/watch?v=K80YEHQpx9g;License: Standard YouTube License, CC-BY
Higher Order Differential Equation with constant coefficient (GATE) (Part 1) l GATE 2018; Author: GATE Lectures by Dishank;https://www.youtube.com/watch?v=ODxP7BbqAjA;License: Standard YouTube License, CC-BY
Solution of Differential Equations and Initial Value Problems; Author: Jefril Amboy;https://www.youtube.com/watch?v=Q68sk7XS-dc;License: Standard YouTube License, CC-BY