Numerical Method For Engineers-Chapter 21
Numerical Method For Engineers-Chapter 21
Numerical Method For Engineers-Chapter 21
CHAPTER 21
21.1 (a) Analytical solution:
( ) [ ] 500168 . 3 5 . 0 0 5 . 0 4 5 . 0 1
) 0 ( 2 ) 4 ( 2
4
0
2
4
0
2
+ +
e e e x dx e
x x
(b) Trapezoidal rule (n = 1):
999329 . 1
2
999665 . 0 0
) 0 4 (
+
I
% 88 . 42 % 100
500168 . 3
999329 . 1 500168 . 3
x x dx x
(b) Trapezoidal rule (n = 1):
78097 . 11
2
6 9
) 0 570796 . 1 (
+
I % 182 . 5 % 100
42478 . 12
78097 . 11 42478 . 12
1
]
1
+ +
x
x
x
x dx x x x
(b) Trapezoidal rule (n = 1):
5280
2
1789 29
)) 2 ( 4 (
+
I % 26 . 378 % 100
1104
5280 1104
1
]
1
+ +
x
x
x
dx /x x
Trapezoidal rule (n = 1):
9
2
9 9
) 1 2 (
+
1
]
1
x dx x
Simpsons rule (n = 4):
% 0 2056
12
4913 ) 1 ( 2 ) 729 343 ( 4 3375
)) 3 ( 5 (
+ + + +
t
I
Simpsons rules (n = 5):
% 0 2056 598 . 5218 6 . 3162
8
4913 ) 016 . 1191 088 . 74 ( 3 648 . 10
) 2 . 0 5 (
6
648 . 10 ) 056 . 636 ( 4 3375
)) 3 ( 2 . 0 (
+
+ + +
+
+
t
I
Because Simpsons rules are perfect for cubics, both versions yield the exact result for this
cubic polynomial.
21.6 Analytical solution:
[ ] 42768 . 98 ) 2 2 (
3
0
2
3
0
2
+
x x
e x x dx e x
Trapezoidal rule (n = 4):
% 062 . 14 2684 . 112
8
7698 . 180 ) 03166 . 48 0838 . 10 190813 . 1 ( 2 0
) 0 3 (
+ + + +
t
I
Simpsons rule (n = 4):
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
5
% 046 . 1 45683 . 99
12
7698 . 180 ) 0838 . 10 ( 2 ) 03166 . 48 190813 . 1 ( 4 0
) 0 3 (
+ + + +
t
I
21.7 Analytical solution:
2301 . 517 14
14 ln 2
1
14
5 . 1
5 . 0
2
1.5
0.5
2
1
]
1
x x
dx
(a) Trapezoidal rule (n = 1):
1379
2
2744 14
) 5 . 0 5 . 1 (
+
I % 612 . 166 % 100
2301 . 517
1379 2301 . 517
x x dx x
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
6
(a) Trapezoidal rule (n = 1):
04503 . 15
2
030023 . 2 8
) 0 3 (
+
I % 453 . 2 % 100
42336 . 15
04503 . 15 42336 . 15
+ + + +
t
I
1
1
]
1
,
_
,
_
9262 . 333 ) 10 (
1 . 68
) 25 . 0 ( 8 . 9
cosh ln
25 . 0
1 . 68
) 10 (
10
0
1
1
]
1
1
1
]
1
,
_
z
Thus, the result to 3 significant digits is 334. Here are results for various multiple-segment
trapezoidal rules:
n I
1 246.9593
2 314.4026
3 325.4835
4 329.216
5 330.9225
6 331.8443
7 332.3984
8 332.7573
9 333.0031
10 333.1788
11 333.3087
12 333.4074
13 333.4842
14 333.5452
Thus, a 14-segment application gives the result to 4 significant digits.
21.10
(a) Trapezoidal rule (n = 5):
15 . 2
10
1 ) 5 5 . 3 4 8 ( 2 1
) 0 5 . 0 (
+ + + + +
I
(b) Simpsons rules (n = 5):
377083 . 2 14375 . 1 233333 . 1
8
1 ) 5 5 . 3 ( 3 4
) 2 . 0 5 . 0 (
6
4 ) 8 ( 4 1
) 0 2 . 0 ( +
+ + +
+
+ +
I
21.11
(a) Trapezoidal rule (n = 6):
65
12
20 ) 3 5 2 10 5 ( 2 35
)) 2 ( 10 (
+ + + + +
I
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
8
(b) Simpsons rules (n = 6):
66667 . 56
18
20 ) 5 10 ( 2 ) 3 2 5 ( 4 35
)) 2 ( 10 (
+ + + + + +
I
21.12 (a) A graph suggests that the mean value is about 80.
y = -0.075x
4
+ 2x
3
- 14x
2
+ 45x - 46
0
50
100
150
200
250
300
0 2 4 6 8 10 12
80
(b) Analytical solution:
[ ]
89333 . 81
8
1467 . 655
2 10
015 . 0 5 . 0 6667 . 4 5 . 22 46
2 10
075 . 0 2 14 45 46
10
2
5 4 3 2
10
2
4 3 2
+ +
+ +
x x x x x
dx x x x x
(c) Numerical solution:
2292 . 654 046 . 601 18315 . 53
8
254 ) 1645 . 156 14368 . 81 ( 3 81888 . 35
) 2 . 5 10 (
6
81888 . 35 ) 27488 . 15 ( 4 8 . 2
) 2 2 . 5 (
+
+ + +
+
+ +
I
% 14 . 0 % 100
89333 . 81
81.77865 89333 . 81
81.77865
2 10
2292 . 654
Average
x x
e dx e
(b) Trapezoidal rule
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
9
79284 . 0
2
8131 . 0 9808 . 0
) 475 . 0 6 . 0 (
2
9808 . 0 1831 . 1
) 35 . 0 475 . 0 (
2
1831 . 1 3746 . 1
) 25 . 0 35 . 0 (
2
3746 . 1 597 . 1
) 15 . 0 25 . 0 (
2
597 . 1 8555 . 1
) 05 . 0 15 . 0 (
2
8555 . 1 2
) 0 05 . 0 (
+
+
+
+
+
+
+
+
+
+
+
I
% 2022 . 0 % 100
79124 . 0
79284 . 0 79124 . 0
+ +
+
+ + +
+
+
I
% 0052 . 0 % 100
79124 . 0
791282 . 0 79124 . 0
t
21.14 (a) Analytical solution:
dy
x
y x y
x
dy dx xy y x
2
2
3
) 2 (
2
0
1
1
2
3 2
3
1
1
2
0
3 2 2
1
]
1
+ +
666667 . 2
2
1
3
4
3
8
2 4
3
8
1
1
4 3
1
1
3 2
1
]
1
+ +
y y y dy y y
(b) Sweeping across the x dimension:
y = 1:
3
4
0 ) 2 ( 2 2
) 0 2 (
+ +
I
y = 0:
3
4
4 ) 1 ( 2 0
) 0 2 (
+ +
I
y = 1:
1
4
4 ) 0 ( 2 2
) 0 2 (
+ +
I
These values can then be integrated along the y dimension:
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
10
2
4
1 ) 3 ( 2 3
)) 1 ( 1 (
+ +
I
% 25 % 100
666667 . 2
2 666667 . 2
t
(c) Sweeping across the x dimension:
y = 1:
33333 . 3
6
0 ) 2 ( 4 2
) 0 2 (
+ +
I
y = 0:
666667 . 2
6
4 ) 1 ( 4 0
) 0 2 (
+ +
I
y = 1:
666667 . 0
6
4 ) 0 ( 4 2
) 0 2 (
+ +
I
These values can then be integrated along the y dimension:
% 0 666667 . 2
6
666667 . 0 ) 666667 . 2 ( 4 33333 . 3
)) 1 ( 1 (
+ +
t
I
21.15 (a) Analytical solution:
dz dy yzx
x
dz dy dx yz x 3
4
) 3 (
1
3
4
2
2
2
0
2
2
2
0
1
3
3
1
]
1
[ ] dz z dz z y y dz dy yz 24 40 6 20 12 20
2
2
2
0
2
2
2
2
2
2
0
[ ] 160 12 40
2
2
2
z z
(b) For z = 2, sweeping across the x dimension:
z = 2; y = 0:
20
6
1 ) 1 ( 4 27
)) 3 ( 1 (
+ +
I
z = 2; y = 1:
4
6
7 ) 5 ( 4 21
)) 3 ( 1 (
+ +
I
z = 2; y = 2:
28
6
13 ) 11 ( 4 15
)) 3 ( 1 (
+ +
I
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
11
These values can then be integrated along the y dimension:
8
6
28 ) 4 ( 4 20
) 0 2 (
+ +
I
For z = 0, similar calculations yield
z = 0; y = 0: I = 20
z = 0; y = 1: I = 20
z = 0; y = 2: I = 20
These values can then be integrated along the y dimension:
40
6
20 ) 20 ( 4 20
) 0 2 (
+
I
For z = 2, similar calculations yield
z = 2; y = 0: I = 20
z = 2; y = 1: I = 44
z = 2; y = 2: I = 68
These values can then be integrated along the y dimension:
88
6
68 ) 44 ( 4 20
) 0 2 (
+
I
Finally, these results can be integrated along the z dimension,
% 0 160
6
88 ) 40 ( 4 8
)) 2 ( 2 (
t
+
I
21.16 Here is a VBA program that is set up to duplicate the computation performed in Example
21.2.
Option Explicit
Sub TestTrapm()
Dim n As Integer, i As Integer
Dim a As Double, b As Double, h As Double
Dim x(100) As Double, f(100) As Double
'Enter data and integration parameters
a = 0
b = 0.8
n = 2
h = (b - a) / n
'generate data from function
x(0) = a
f(0) = fx(a)
For i = 1 To n
x(i) = x(i - 1) + h
f(i) = fx(x(i))
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
12
Next i
'invoke function to determine and display integral
MsgBox "The integral is " & Trapm(h, n, f)
End Sub
Function Trapm(h, n, f)
Dim i As Integer, sum As Double
sum = f(0)
For i = 1 To n - 1
sum = sum + 2 * f(i)
Next i
sum = sum + f(n)
Trapm = h * sum / 2
End Function
Function fx(x)
fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5
End Function
21.17 Here is a VBA program that is set up to duplicate the computation performed in Example
21.5.
Option Explicit
Sub TestSimpm()
Dim n As Integer, i As Integer
Dim a As Double, b As Double, h As Double
Dim x(100) As Double, f(100) As Double
'Enter data and integration parameters
a = 0
b = 0.8
n = 4
h = (b - a) / n
'generate data from function
x(0) = a
f(0) = fx(a)
For i = 1 To n
x(i) = x(i - 1) + h
f(i) = fx(x(i))
Next i
'invoke function to determine and display integral
MsgBox "The integral is " & Simp13m(h, n, f)
End Sub
Function Simp13m(h, n, f)
Dim i As Integer
Dim sum As Double
sum = f(0)
For i = 1 To n - 2 Step 2
sum = sum + 4 * f(i) + 2 * f(i + 1)
Next i
sum = sum + 4 * f(n - 1) + f(n)
Simp13m = h * sum / 3
End Function
Function fx(x)
fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5
End Function
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
13
21.18 Here is a VBA program that is set up to duplicate the computation performed in Example
21.8.
Option Explicit
Sub TestUneven()
Dim n As Integer, i As Integer
Dim label As String
Dim a As Double, b As Double, h As Double
Dim x(100) As Double, f(100) As Double
'Enter data
Sheets("Sheet1").Select
Range("a6").Select
n = ActiveCell.Row
Selection.End(xlDown).Select
n = ActiveCell.Row - n
'Input data from sheet
Range("a6").Select
For i = 0 To n
x(i) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
f(i) = ActiveCell.Value
ActiveCell.Offset(1, -1).Select
Next i
'invoke function to determine and display integral
MsgBox "The integral is " & Uneven(n, x, f)
End Sub
Function Uneven(n, x, f)
Dim k As Integer, j As Integer
Dim h As Double, sum As Double, hf As Double
h = x(1) - x(0)
k = 1
sum = 0#
For j = 1 To n
hf = x(j + 1) - x(j)
If Abs(h - hf) < 0.000001 Then
If k = 3 Then
sum = sum + Simp13(h, f(j - 3), f(j - 2), f(j - 1))
k = k - 1
Else
k = k + 1
End If
Else
If k = 1 Then
sum = sum + Trap(h, f(j - 1), f(j))
Else
If k = 2 Then
sum = sum + Simp13(h, f(j - 2), f(j - 1), f(j))
Else
sum = sum + Simp38(h, f(j - 3), f(j - 2), f(j - 1), f(j))
End If
k = 1
End If
End If
h = hf
Next j
Uneven = sum
End Function
Function Trap(h, f0, f1)
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
14
Trap = h * (f0 + f1) / 2
End Function
Function Simp13(h, f0, f1, f2)
Simp13 = 2 * h * (f0 + 4 * f1 + f2) / 6
End Function
Function Simp38(h, f0, f1, f2, f3)
Simp38 = 3 * h * (f0 + 3 * (f1 + f2) + f3) / 8
End Function
Function fx(x)
fx = 0.2 + 25 * x - 200 * x ^ 2 + 675 * x ^ 3 - 900 * x ^ 4 + 400 * x ^ 5
End Function
To run the program, the data is entered in columns A and B on a worksheet labeled Sheet1.
After the macro is run, a message box displays the integral estimate as shown.
21.19 (a) Analytical solution:
[ ] 9167 . 165 0.083333 5 0.25 5
11
0
3
11
0
2
+ +
x x dx x M
(b) Trapezoidal rule:
375 . 166
2
6 25 . 5
) 1 2 (
2
25 . 5 5
) 0 1 ( +
+
+
+
I
(c) Simpsons rule:
9167 . 165
6
9 ) 25 . 7 ( 4 6
) 2 4 (
6
6 ) 25 . 5 ( 4 5
) 0 2 ( +
+ +
+
+ +
I
21.20 Trapezoidal/Simpsons rules
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
15
192 . 2681
2
6 . 165 6 . 193
) 10 11 (
8
6 . 193 ) 6 . 249 5 . 260 ( 3 8 . 260
) 4 10 (
6
8 . 260 ) 4 . 266 ( 4 4 . 294
) 2 4 (
2
4 . 294 336
) 5 . 0 2 (
+
+
+ + +
+
+ +
+
+
I
21.21 (a) Trapezoidal rule
m 5 . 622 , 3
min
s 60
s
min m
375 . 60
2
5 . 5 6
) 2 25 . 3 (
2
6 5
) 1 2 (
+
+
+
+
I
(b) Trapezoidal/Simpsons rules
m 25 . 596 , 3
min
s 60
s
min m
9375 . 59
6
5 ) 7 ( 4 7
) 9 10 (
8
7 ) 6 8 ( 3 5 . 8
) 6 9 (
2
5 . 8 7
) 5 . 4 6 (
6
7 ) 5 . 5 ( 4 6
) 2 5 . 4 (
2
6 5
) 1 2 (
+ +
+
+ + +
+
+
+
+ +
+
+
I
(c) We can use regression to fit a quadratic equation to the data
y = -0.1117x
2
+ 1.3526x + 3.4447
R
2
= 0.5742
0
5
10
0 2 4 6 8 10 12
This equation can be integrated to yield
[ ]
m 594 . 645 , 3
min
s 60
s
min m
7599 . 60
3.4447 + 0.6763 + 03723 . 0 3.4447 + 1.3526 + 0.1117
10
1
2 3
10
1
2
x x x dx x x M
We can use regression to fit a cubic equation to the data
y = -0.01646x
3
+ 0.16253x
2
+ 0.07881x + 4.85467
R
2
= 0.63442
0
5
10
0 2 4 6 8 10 12
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
16
This equation can be integrated to yield
[ ]
m 184 . 634 , 3
min
s 60
s
min m
56973 . 60
4.85467 + 0.039405 + 0.054177 + 00412 . 0
4.85467 0.07881x + 0.16253 + 0.01646
10
1
2 3 4
10
1
2 3
x x x x
dx x x M
21.22 We can set up a table that contains the values comprising the integrand
x, cm , g/cm
3
Ac, cm
2
Ac,
g/cm
0 4 100 400
200 3.95 103 406.85
300 3.89 106 412.34
400 3.8 110 418
600 3.6 120 432
800 3.41 133 453.53
1000 3.3 150 495
We can integrate this data using a combination of the trapezoidal and Simpsons rules,
kg 430.8779 g 9 . 877 , 430
8
495 ) 53 . 453 432 ( 3 418
) 400 1000 (
6
418 ) 34 . 412 ( 4 85 . 406
) 200 400 (
2
85 . 406 400
) 0 200 (
+ + +
+
+ +
+
+
I
21.23 We can set up a table that contains the values comprising the integrand
t, hr t, d
rate
(cars/4 min)
rate
(cars/d)
7:30 0.312500 18 6480
7:45 0.322917 24 8640
8:00 0.333333 14 5040
8:15 0.343750 24 8640
8:45 0.364583 21 7560
9:15 0.385417 9 3240
We can integrate this data using a combination of Simpsons 3/8 and 1/3 rules. This yields the
number of cars that go through the intersection between 7:30 and 9:15,
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.
17
cars 511.875 292.5 219.375
6
3240 ) 7560 ( 4 8640
) 34375 . 0 385417 . 0 (
8
8640 ) 5040 8640 ( 3 6480
) 3125 . 0 34375 . 0 (
+
+ +
+
+ + +
I
The number of cars going through the intersection per minute can be computed as
min
cars
875 . 4
min 60
hr
hr 1.75
cars 511.875
21.24 We can use Simpsons 1/3 rule to integrate across the y dimension,
x = 0:
3333 . 17
6
8 ) 4 ( 4 2
) 0 4 (
+
I
x = 4:
14
6
8 ) 3 ( 4 1
) 0 4 (
+
I
x = 8:
3333 . 1
6
6 ) 1 ( 4 4
) 0 4 (
+
I
x = 12:
28
6
4 ) 7 ( 4 10
) 0 4 (
+ +
I
These values can then be integrated along the x dimension with Simpsons 3/8 rule:
41
8
28 ) 3333 . 1 14 ( 3 3333 . 17
) 0 12 (
+ + +
I
PROPRIETARY MATERIAL. The McGraw-Hill Companies, Inc. All rights reserved. No part of this Manual may
be displayed, reproduced or distributed in any form or by any means, without the prior written permission of the
publisher, or used beyond the limited distribution to teachers and educators permitted by McGraw-Hill for their individual
course preparation. If you are a student using this Manual, you are using it without permission.