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

Videos

Textbook Question
Book Icon
Chapter 28, Problem 18P

Perform the same computation for the Lorenz equations in Sec. 28.2, but use (a) Euler's method, (b) Heun's method (without iterating the corrector), (c) the fourth-order RK method, and (d) the MATLAB ode45 function. In all cases use single-precision variables and a step size of 0.1 and simulate from t = 0 to 20. Develop phase-plane plots for all cases.

(a)

Expert Solution
Check Mark
To determine

To calculate: The solution of Lorentz equation dxdt=10x+10y, dydt=28xyxz and dzdt=2.666667z+xy by the Euler’s method with the step size of 0.1 from t=0 to 20. Also plot the result and the phase-plane plot.

Answer to Problem 18P

Solution:

The solution of Lorentz equations by the Euler’s method with step size 0.1 gives unstable solution.

Explanation of Solution

Given Information:

Lorentz equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

and Initial conditions are x=y=z=5.

Formula used:

Euler’s method for dydx=f(x,y) is,

y(x+h)=y(x)+hf(x,y)

Where, h is the step size.

Calculation:

Consider the equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

The iteration formula for Euler’s method with step size Δt=0.1 for the above equations are,

x(t+0.1)=x(t)+0.1(10x+10y)y(t+0.1)=y(t)+0.1(28xyxz)z(t+0.1)=z(t)+0.1(2.666667z+xy)

Use excel to find all the iteration with step size Δt=0.1 as below,

Step 1: Name the column A as t and go to column A2 and put 0 then go to column A3 and write the formula as,

=A2+0.1

Then, Press enter and drag the column up to t=20.

Step 2: Now name the column B as x-Euler and go to column B2 and write 5 and then go to the column B3 and write the formula as,

=B2+0.1*(-10*B2+10*C2)

Step 3: Press enter and drag the column up to t=20.

Step 4: Now name the column C as y-Euler and go to column C2 and write 5 and then go to the column C3 and write the formula as,

=C2+0.1*(28*B2-C2-B2*D2)

Step 5: Press enter and drag the column up to t=20.

Step 6: Now name the column D as z-Euler and go to column D2 and write 5 and then go to the column D3 and write the formula as,

=D2+0.1*(-2.666667*D2+B2*C2)

Step 7: Press enter and drag the column up to t=20.

Thus, first few iterations are as shown below,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  1

From the above result, it is observed that the solution of Lorentz equations by the Euler’s method with step size 0.1 the values are continuously decreasing. Hence, Euler method with step size 0.1 gives unstable solution for the Lorentz equations.

(b)

Expert Solution
Check Mark
To determine

To calculate: The solution of Lorentz equation dxdt=10x+10y, dydt=28xyxz and dzdt=2.666667z+xy by the Heun’s method with the step size of 0.1 from t=0 to 20. Also plot the result and the phase-plane plot.

Answer to Problem 18P

Solution:

The solution of Lorentz equations by the Heun’s method with step size 0.1 gives unstable solution.

Explanation of Solution

Given Information:

Lorentz equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

and Initial conditions are x=y=z=5.

Formula used:

The iteration formula for Heun’s method is,

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

Calculation:

Consider the equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

The following VBA code is used to solve the Lorentz equation by Heun’s method:

Code:

OptionExplicit

'Generate a function find

Subfind()

'Declare the variables

Dim t AsDouble,x AsDouble,h AsDouble,hhAsDouble,y AsDouble,z AsDouble,g AsDouble,r AsDouble

'Set the values for variables

t =0

x =5

h =0.1

y =5

z =5

g =28

r =28

'move to the cell b3

Range("b3").Select

ActiveCell. Value="Heun Method"

'Assign name to the columns

ActiveCell. Offset(1, 0).Select

ActiveCell. Value="t"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="x"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="y"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="z"

'call the Heun function

hh=Heun(t,x,h,y,z)

EndSub

'Define Heun function

FunctionHeun(t,x,h,y,z)

'Declare the variables

Dim dx1dt AsDouble,slpxAsDouble,dx2dt AsDouble,cexAsDouble,xnewAsDouble,dz2dt AsDouble,znewAsDouble

Dim dy1dt AsDouble,dz1dt AsDouble,slpyAsDouble,dy2dt AsDouble,ceyAsDouble,ynewAsDouble,slpzAsDouble,cezAsDouble

Dim j AsInteger

'Use for loop to find the different value of x

For j =1To200

'move to cell b4

Range("b4").Select

'Display the values of t, x, y and z

ActiveCell. Offset(j, 0).Select

ActiveCell. Value= t

ActiveCell. Offset(0, 1).Select

ActiveCell. Value= x

ActiveCell. Offset(0, 1).Select

ActiveCell. Value= y

ActiveCell. Offset(0, 1).Select

ActiveCell. Value= z

'call drive function for dx1dt

dx1dt =drivex(t,x)

cex= x +(dx1dt * h)

'call drive function for dx2dt

dx2dt =drivex(t + h,cex)

slpx=(dx1dt + dx2dt)/2

'Write the formula for next value of x

xnew= x +slpx* h

x =xnew

'call drive function for dy1dt

dy1dt =drivey(t,y)

cey= y +(dy1dt * h)

'call drive function for dy2dt

dy2dt =drivey(t + h,cey)

slpy=(dy1dt + dy2dt)/2

'Write the formula for next value of y

ynew= y +slpy* h

y =ynew

'call drive function for dz1dt

dz1dt =drivey(t,z)

cez= z +(dz1dt * h)

'call drive function for dz2dt

dz2dt =drivez(t + h,cez)

slpz=(dz1dt + dz2dt)/2

'Write the formula for next value of z

znew= z +slpz* h

z =znew

'Write the formula for next value of t

t = t + h

Next

EndFunction

'define drivex function

Functiondrivex(t,x)

Dim temp AsDouble

'find the value of derivative

temp =-(28* x)+(28*5)

drivex= temp

EndFunction

'define drivey function

Functiondrivey(t,y)

Dim temp AsDouble

'find the value of derivative

temp =(28*5)+(y)-(5*5)

drivey= temp

EndFunction

'define drivez function

Functiondrivez(t,z)

Dim temp AsDouble

'find the value of derivative

temp =-(5* z)+(5*5)

drivez= temp

EndFunction

Output:

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  2

To draw the graph of the above results, follow the steps in excel sheet as given below,

Step 1: Select the cell from A4 to A205 and cell B4 to B205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 2: Select the cell from A4 to A205 and cell C4 to C205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 2: Select the cell from A4 to A205 and cell D4 to D205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 4: Select one of the graphs and paste it on another graph to merge the graphs.

The graph obtained is,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  3

And, to draw the phase plane plot follow the steps as below,

Step 4: Select the column B, column C and column D. Then, go to the Insert and select the scatter with smooth lines from the chart.

The graph obtained is,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  4

The phase plane plot is a straight line because solution of x is a constant value. The solution o0f Lorentz equation by Heun’s method with step size 0.1 is thus unstable.

(c)

Expert Solution
Check Mark
To determine

To calculate: The solution of Lorentz equation dxdt=10x+10y, dydt=28xyxz and dzdt=2.666667z+xy by the fourth-order RK method with the step size of 0.1 from t=0 to 20. Also plot the result and the phase-plane plot.

Answer to Problem 18P

Solution:

The first few solutions of Lorentz equation are,

t x y z
0 5 5 5
0.1 9.781196 17.07821 10.44315
0.2 17.69946 20.86553 35.90347
0.3 10.80352 -2.53933 39.32018
0.4 0.539054 -5.55832 28.10261
0.5 -3.17668 -5.85077 22.41242
0.6 -5.5818 -8.41419 19.9751
0.7 -8.8743 -12.6404 22.17497
0.8 -11.8816 -13.3924 29.76851
0.9 -10.6546 -7.2405 33.36662
1 -6.86073 -3.45687 29.32358

Explanation of Solution

Given Information:

Lorentz equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

and Initial conditions are x=y=z=5.

Formula used:

The fourth-order RK method for dydt=f(t,y) is,

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

Where,

k1=hf(tn,yn)k2=hf(tn+h2,yn+k12)k3=hf(tn+h2,yn+k22)k4=hf(tn+h,yn+k3)

Calculation:

The following VBA code is used to find the solution of Lorentz equation by the fourth order RK method:

Code:

OptionExplicit

' Generate a subfunction RK4

Sub RK4()

'Declare the variables as integer

DimiAsInteger,m AsInteger,n AsInteger,j AsInteger

'Declare the variables as double

Dimx_iAsDouble,y_i(10)AsDouble,x_fAsDouble

DimdiffxAsDouble,x_outAsDouble

Dimx_p(200)AsDouble,y_p(200, 10)AsDouble

'Set the values

n =3

x_i=0

x_f=20

y_i(1)=5

y_i(2)=5

y_i(3)=5

diffx=0.1

x_out=0.1

'move to the cell b3

Range("a3").Select

ActiveCell. Value="RK4 Method"

'Assign name to the columns

ActiveCell. Offset(1, 0).Select

ActiveCell. Value="t"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="x"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="y"

ActiveCell. Offset(0, 1).Select

ActiveCell. Value="z"

' Call ODESolver to solve the differential equations

CallODESolver(x_i,y_i,x_f,diffx,x_out,x_p,y_p,m,n)

'Display the results

Sheets("Sheet1").Select

Range("a5:n205").ClearContents

Range("a5").Select

'Use for loop to store different values of x_p

Fori=0To m

ActiveCell. Value=x_p(i)

'Use for loop to store different values of y_p

For j =1To n

'Define the offset

ActiveCell. Offset(0, 1).Select

ActiveCell. Value=y_p(i,j)

Next j

'Define the offset

ActiveCell. Offset(1,-n).Select

Nexti

Range("a5").Select

EndSub

' Define subfunction ODESolver

SubODESolver(x_i,y_i,x_f,diffx,x_out,x_p,y_p,m,n)

'Declare the variables as integer

DimiAsInteger

'Declare the variables as double

Dim x AsDouble,y(10)AsDouble,x_endAsDouble

Dim h AsDouble

'Set the variable m

m =0

'Store the value of x_i in x

x =x_i

'Use for loop to store different values of y_i in y

Fori=1To n

y(i)=y_i(i)

Nexti

'Store the value of x in x_p

x_p(m)= x

'Use for loop to store different values of y in y_p

Fori=1To n

y_p(m,i)= y(i)

Nexti

'Use the condition to find the next x values

Do

x_end= x +x_out

If(x_end>x_f)Thenx_end=x_f

h =diffx

'Call the Integrator function

CallIntegrator(x,y,h,n,x_end)

m = m +1

'Store the value of x in x_p

x_p(m)= x

'Use for loop to store different values of y in y_p

Fori=1To n

y_p(m,i)= y(i)

Nexti

'Use condition to exit the loop

If(x >=x_f)ThenExitDo

Loop

EndSub

'Define the subfunction Integrator

SubIntegrator(x,y,h,n,x_end)

'Declare the variables

Dim j AsInteger

Dimynew(10)AsDouble

'Use conditions for calculation

Do

If(x_end- x < h)Then h =x_end- x

'Call the RK4sys function

Call RK4Sys(x,y,h,n,ynew)

For j =1To n

'Store the different values of ynew in y

y(j)=ynew(j)

Next j

'Use condition to exit the loop

If(x >=x_end)ThenExitDo

Loop

EndSub

' create a subfunction RK4sys

Sub RK4Sys(x,y,h,n,ynew)

'Declare the variables as integer

Dim j AsInteger

'Declare the variables as double

Dimy_m(10)AsDouble,y_e(10)AsDouble

Dim k_1(10)AsDouble,k_2(10)AsDouble,k_3(10)AsDouble,k_4(10)AsDouble

Dimslope(10)

'Call the Derivs function

CallDerivs(x,y,k_1)

'Use for loop to store different values of y_m

For j =1To n

'Assign the different values of y(j) + k_1(j) * h / 2 to y_m

y_m(j)= y(j)+ k_1(j)* h /2

Next j

'Call the Derivs function

CallDerivs(x + h /2,y_m,k_2)

'Use for loop to store different values of y_m

For j =1To n

'Assign the different values of y(j) + k_2(j) * h / 2 to y_m

y_m(j)= y(j)+ k_2(j)* h /2

Next j

'Call the Derivs function

CallDerivs(x + h /2,y_m,k_3)

'Use for loop to store different values of y_e

For j =1To n

'Assign the different values of y(j) + k_3(j) * h to y_e

y_e(j)= y(j)+ k_3(j)* h

Next j

'Call the Derivs function

CallDerivs(x + h,y_e,k_4)

'Use for loop to store different values of slope

For j =1To n

'Assign the different value of k_1(j) + 2 * (k_2(j) + k_3(j)) + k_4(j)) / 6 to slope(j)

slope(j)=(k_1(j)+2*(k_2(j)+ k_3(j))+ k_4(j))/6

Next j

'Use for loop to store different values of ynew

For j =1To n

'Assign the different values of y(j) + slope(j) * h to ynew(j)

ynew(j)= y(j)+ slope(j)* h

Next j

'Write the next x value

x = x + h

EndSub

' Define the subfunction Derivs

SubDerivs(x,y,dydx)

'Write the ordinary differential equations

dydx(1)=-10* y(1)+10* y(2)

dydx(2)=28* y(1)- y(2)- y(1)* y(3)

dydx(3)=-2.66* y(3)+ y(1)* y(2)

EndSub

Output:

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  5

To draw the graph of the above results, follow the steps in excel sheet as given below,

Step 1: Select the cell from A4 to A205 and cell B4 to B205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 2: Select the cell from A4 to A205 and cell C4 to C205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 3: Select the cell from A4 to A205 and cell D4 to D205. Then, go to the Insert and select the scatter with smooth lines from the chart.

Step 4: Select one of the graphs and paste it on another graph to merge the graphs.

The graph obtained is,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  6

And, to draw the phase plane plot follow the steps as below,

Step 4: Select the column B, column C and column D. Then, go to the Insert and select the scatter with smooth lines from the chart.

The graph obtained is,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  7

(d)

Expert Solution
Check Mark
To determine

The solution of Lorentz equation dxdt=10x+10y, dydt=28xyxz and dzdt=2.666667z+xy by the MATLAB ode45 function with the step size of 0.1 from t=0 to 20. Also plot the result and the phase-plane plot.

Answer to Problem 18P

Solution:

The solution graph of Lorentz equation is,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  8

Explanation of Solution

Given Information:

Lorentz equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

and Initial conditions are x=y=z=5.

Consider the Lorentz equations,

dxdt=10x+10ydydt=28xyxzdzdt=2.666667z+xy

Use MATLAB ode45 function to solve the above differential functions as below,

Code:

%create the function lorenz

functionyp=lorenz(t, y)

%Write the equations

yp=[-10*y(1)+10*y(2);28*y(1)-y(2)-y(1)*y(3);-2.666667*y(3)+y(1)*y(2)];

Output:

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  9

The graph obtained as,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  10

Write the command as below to plot the phase-plane,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  11

The phase plane graph obtained as,

Numerical Methods for Engineers, Chapter 28, Problem 18P , additional homework tip  12

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 28 Solutions

Numerical Methods for Engineers

Ch. 28 - An on is other malbatchre actor can be described...Ch. 28 - The following system is a classic example of stiff...Ch. 28 - 28.13 A biofilm with a thickness grows on the...Ch. 28 - 28.14 The following differential equation...Ch. 28 - Prob. 15PCh. 28 - 28.16 Bacteria growing in a batch reactor utilize...Ch. 28 - 28.17 Perform the same computation for the...Ch. 28 - Perform the same computation for the Lorenz...Ch. 28 - The following equation can be used to model the...Ch. 28 - Perform the same computation as in Prob. 28.19,...Ch. 28 - 28.21 An environmental engineer is interested in...Ch. 28 - 28.22 Population-growth dynamics are important in...Ch. 28 - 28.23 Although the model in Prob. 28.22 works...Ch. 28 - 28.25 A cable is hanging from two supports at A...Ch. 28 - 28.26 The basic differential equation of the...Ch. 28 - 28.27 The basic differential equation of the...Ch. 28 - A pond drains through a pipe, as shown in Fig....Ch. 28 - 28.29 Engineers and scientists use mass-spring...Ch. 28 - Under a number of simplifying assumptions, the...Ch. 28 - 28.31 In Prob. 28.30, a linearized groundwater...Ch. 28 - The Lotka-Volterra equations described in Sec....Ch. 28 - The growth of floating, unicellular algae below a...Ch. 28 - 28.34 The following ODEs have been proposed as a...Ch. 28 - 28.35 Perform the same computation as in the first...Ch. 28 - Solve the ODE in the first part of Sec. 8.3 from...Ch. 28 - 28.37 For a simple RL circuit, Kirchhoff’s voltage...Ch. 28 - In contrast to Prob. 28.37, real resistors may not...Ch. 28 - 28.39 Develop an eigenvalue problem for an LC...Ch. 28 - 28.40 Just as Fourier’s law and the heat balance...Ch. 28 - 28.41 Perform the same computation as in Sec....Ch. 28 - 28.42 The rate of cooling of a body can be...Ch. 28 - The rate of heat flow (conduction) between two...Ch. 28 - Repeat the falling parachutist problem (Example...Ch. 28 - 28.45 Suppose that, after falling for 13 s, the...Ch. 28 - 28.46 The following ordinary differential equation...Ch. 28 - 28.47 A forced damped spring-mass system (Fig....Ch. 28 - 28.48 The temperature distribution in a tapered...Ch. 28 - 28.49 The dynamics of a forced spring-mass-damper...Ch. 28 - The differential equation for the velocity of a...Ch. 28 - 28.51 Two masses are attached to a wall by linear...
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
Advanced Engineering Mathematics
Advanced Math
ISBN:9780470458365
Author:Erwin Kreyszig
Publisher:Wiley, John & Sons, Incorporated
Text book image
Numerical Methods for Engineers
Advanced Math
ISBN:9780073397924
Author:Steven C. Chapra Dr., Raymond P. Canale
Publisher:McGraw-Hill Education
Text book image
Introductory Mathematics for Engineering Applicat...
Advanced Math
ISBN:9781118141809
Author:Nathan Klingbeil
Publisher:WILEY
Text book image
Mathematics For Machine Technology
Advanced Math
ISBN:9781337798310
Author:Peterson, John.
Publisher:Cengage Learning,
Text book image
Basic Technical Mathematics
Advanced Math
ISBN:9780134437705
Author:Washington
Publisher:PEARSON
Text book image
Topology
Advanced Math
ISBN:9780134689517
Author:Munkres, James R.
Publisher:Pearson,
Intro to the Laplace Transform & Three Examples; Author: Dr. Trefor Bazett;https://www.youtube.com/watch?v=KqokoYr_h1A;License: Standard YouTube License, CC-BY