Professional Documents
Culture Documents
Chapra Numerical Analysis 18th Chapter Solution PDF Free
Chapra Numerical Analysis 18th Chapter Solution PDF Free
CHAPTER 18
18.1 (a)
1.0791812 0.90309
f1 (10) 0.90309 (10 8) 0.991136
12 8
1 0.991136
t 100% 0.886%
1
(b)
1.0413927 0.9542425
f1 (10) 0.9542425 (10 9) 0.997818
11 9
1 0.997818
t 100% 0.218%
1
x0 = 9 f(x0) = 0.9542425
x1 = 11 f(x1) = 1.0413927
x2 = 8 f(x2) = 0.9030900
b0 = 0.9542425
1.0413927 0.9542425
b1 0.0435751
11 9
0.9030900 1.0413927
0.0435751
8 11 0.0461009 0.0435751
b2 0.0025258
89 89
Substituting these values into Eq. (18.3) yields the quadratic formula
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.
2
x0 = 9 f(x0) = 0.9542425
x1 = 11 f(x1) = 1.0413927
x2 = 8 f(x2) = 0.9030900
x3 = 12 f(x3) = 1.0791812
1.0413927 0.9542425
f [ x1 , x0 ] 0.0435751
11 9
0.9030900 1.0413927
f [ x 2 , x1 ] 0.0461009
8 11
1.0791812 0.9030900
f [ x3 , x 2 ] 0.0440228
12 8
0.0461009 0.0435751
f [ x2 , x1 , x0 ] 0.0025258
89
0.0440228 0.0461009
f [ x3 , x 2 , x1 ] 0.0020781
12 11
0.0020781 (0.0025258)
f [ x3 , x2 , x1 , x0 ] 0.00014924
12 9
18.4 First, order the points so that they are as close to and as centered about the unknown as
possible
x0 = 2.5 f(x0) = 14
x1 = 3.2 f(x1) = 15
x2 = 2 f(x2) = 8
x3 = 4 f(x3) = 8
x4 = 1.6 f(x4) = 2
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.
3
Next, the divided differences can be computed and displayed in the format of Fig. 18.5,
The errors estimates for the first and second-order predictions can be computed with Eq.
18.19 as
The error for the third-order prediction can be computed with Eq. 18.18 as
18.5 First, order the points so that they are as close to and as centered about the unknown as
possible
x0 = 3 f(x0) = 19
x1 = 5 f(x1) = 99
x2 = 2 f(x2) = 6
x3 = 7 f(x3) = 291
x4 = 1 f(x4) = 3
Next, the divided differences can be computed and displayed in the format of Fig. 18.5,
f 1 (4) 19 40 (4 3) 59
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.
4
Clearly this data was generated with a cubic polynomial since the difference between the 4th
and the 3rd-order versions is zero.
18.6
18.1 (a):
x0 = 8 f(x0) = 0.9030900
x1 = 12 f(x1) = 1.0791812
10 12 10 8
f1 (10) 0.9030900 1.0791812 0.991136
8 12 12 8
18.1 (b):
x0 = 9 f(x0) = 0.9542425
x1 = 11 f(x1) = 1.0413927
10 11 10 9
f1 (10) 0.9542425 1.0413927 0.997818
9 11 11 9
18.2:
x0 = 8 f(x0) = 0.9030900
x1 = 9 f(x1) = 0.9542425
x2 = 11 f(x2) = 1.0413927
(10 9)(10 11) (10 8)(10 11)
f 2 (10 ) 0.9030900 0.9542425
(8 9)(8 11) (9 8)(9 11)
(10 8)(10 9)
1.0413927 1.0003434
(11 8)(11 9)
18.3:
x0 = 8 f(x0) = 0.9030900
x1 = 9 f(x1) = 0.9542425
x2 = 11 f(x2) = 1.0413927
x3 = 12 f(x3) = 1.0791812
(10 9)(10 11)(10 12 ) (10 8)(10 11)(10 12 )
f 3 (10 ) 0.9030900 0.9542425
(8 9)(8 11)(8 12 ) (9 8)(9 11)(9 12 )
(10 8)(10 9)(10 12 ) (10 8)(10 9)(10 11)
1.0413927 1.0791812 1.0000449
(11 8)(11 9)(11 12 ) (12 8)(12 9)(12 11)
18.7
First order:
x0 = 3 f(x0) = 19
x1 = 5 f(x1) = 99
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
45 43
f1 (10) 19 99 59
35 53
Second order:
x0 = 3 f(x0) = 19
x1 = 5 f(x1) = 99
x2 = 2 f(x2) = 6
(4 5)(4 2) (4 3)(4 2) (4 3)(4 5)
f 2 (10 ) 19 99 6 50
(3 5)(3 2) (5 3)(5 2) (2 3)(2 5)
Third order:
x0 = 3 f(x0) = 19
x1 = 5 f(x1) = 99
x2 = 2 f(x2) = 6
x3 = 7 f(x3) = 291
(4 5)( 4 2)( 4 7) (4 3)( 4 2)( 4 7)
f 3 (10 ) 19 99
(3 5)(3 2)(3 7) (5 3)(5 2)(5 7)
(4 3)( 4 5)( 4 7) (4 3)( 4 5)( 4 2)
6 291 48
(2 3)( 2 5)( 2 7) (7 3)(7 5)(7 2)
18.8 The following points are used to generate a cubic interpolating polynomial
x0 = 3 f(x0) = 0.3333
x1 = 4 f(x1) = 0.25
x2 = 5 f(x2) = 0.2
x3 = 6 f(x3) = 0.1667
The polynomial can be generated in a number of ways including simultaneous equations (Eq.
18.26) or a software tool. The result is
The roots problem can then be developed by setting this polynomial equal to the desired
value of 0.23
Bisection can then be used to determine the root. Using initial guesses of xl = 4 and xu = 5, the
first five iterations are
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
18.9 [Errata: Note that in the first printing, the function for this problem was erroneously
shown as f(x) = x3/(2 + x3). The correct formula, which appears in subsequent printings
is f(x) = x2/(1 + x2).]
(a) Analytically
x2
0.85
1 x2
0.85 0.85 x 2 x 2
x 0.85 / 0.15 2.380476
y0 = 0.5 x0 = 1
y1 = 0.8 x1 = 2
y2 = 0.9 x2 = 3
y3 = 0.941176 x3 = 4
x 62 .971 282 .46 (0.85) 404 .83(0.85) 2 191 .59 (0.85) 3 2.290694
2.380476 2.290694
t 100 % 3.77 %
2.380476
x0 = 2 f(x0) = 0.8
x1 = 3 f(x1) = 0.9
x2 = 4 f(x2) = 0.941176
The roots problem can then be developed by setting this polynomial equal to the desired
value of 0.85 to give
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.
7
2.380476 2.428009
t 100 % 2.00 %
2.380476
x0 = 1 f(x0) = 0.5
x1 = 2 f(x1) = 0.8
x2 = 3 f(x2) = 0.9
x3 = 4 f(x3) = 0.941176
The roots problem can then be developed by setting this polynomial equal to the desired
value of 0.85
Bisection can then be used to determine the root. Using initial guesses of xl = 2 and xu = 3, the
first five iterations are
2.380476 2.345481
t 100 % 1.47 %
2.380476
18.10 For the present problem, we have five data points and n = 4 intervals. Therefore, 3(4) = 12
unknowns must be determined. Equations 18.29 and 18.30 yield 2(4) – 2 = 6 conditions
4a1 2b1 c1 8
4a 2 2b2 c 2 8
6.25 a 2 2.5b2 c 2 14
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
6.25 a 3 2.5b3 c3 14
10 .24 a 3 3.2b3 c3 15
10 .24 a 4 3.2b4 c 4 15
Passing the first and last functions through the initial and final values adds 2 more
2.56 a1 1.6b1 c1 2
16 a 4 4b4 c 4 8
4a1 b1 4a 2 b2
5a 2 b2 5a 3 b3
6.4a 3 b3 6.4a 4 b4
Finally, Eq. 18.34 specifies that a1 = 0. Thus, the problem reduces to solving 11 simultaneous
equations for 11 unknown coefficients,
b1
2 1 0 0 0 0 0 0 0 0 0 c 8
0 0 4 2 1 0 0 0 0 0 0 a1 8
0 0 6.25 2.5 1 0 0 0 0 0 0 2 14
0 0 0 0 0 6.25 2.5 1 0 0 0 b2 14
0 0 0 0 0 10 .24 3.2 1 0 0 0 c 2 15
0 0 0 0 0 0 0 0 10 .24 3.2 1 a 3 15
1.6 1 0 0 0 0 0 0 0 0 0 b3 2
0 0 0 0 0 0 0 0 16 4 1 c 8
1 0 4 1 0 0 0 0 0 0 0 3 0
0 0 5 1 0 5 1 0 0 0 0 a 4 0
0 1 0 6 .4 1 0 b4 0
0 0 0 0 6.4
c 4
which can be solved for
b1 = 15 c1 = 22
a2 = 6 b2 = 39 c2 = 46
a3 = 10.816327 b3 = 63.081633 c3 = 76.102041
a4 = 3.258929 b4 = 14.714286 c4 = 1.285714
Finally, here is a plot of the data along with the quadratic spline,
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
20
spline
15 data
10
0
0 1 2 3 4 5
x0 = 1 f(x0) = 3
x1 = 2 f(x1) = 6
x2 = 3 f(x2) = 19
6 6
(2 1) f " (1) 2(3 1) f " (2) (3 2) f " (3) (19 6) (3 6)
32 2 1
Because of the natural spline condition, f”(1) = 0, and the equation reduces to
Equations can be written for the remaining interior knots and the results assembled in matrix
form as
4 1 0 0 f " (2) 60
1 6 2 0 f " (3) 162
0 2 8 2 f " (5) 336
0 0 2 6 f " (7) 342
These values can be used in conjunction with Eq. 18.36 to yield the following interpolating
splines for each interval,
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
The interpolating splines can be used to make predictions along the interval. The results are
shown in the following plot.
500
400
300
200
100
0
0 2 4 6 8
f3(4) = 48.41157
f2(2.5) = 10.78384
(b)
f 2 (3) 1.80786 (3 3) 3 2.768559 (3 2) 3 4.19214 (3 3) 16 .23144 (3 2) 19
f 3 (3) 1.384279 (5 3) 3 2.145197 (3 3) 3 3.962882 (5 3) 40 .91921 (3 3) 19
x0 = 3.2 f(x0) = 15
x1 = 4 f(x1) = 8
x2 = 4.5 f(x2) = 2
a 0 3.2a1 10 .24 a 2 15
a 0 4a1 16 a 2 8
a 0 4.5a1 20 .25 a 2 2
These can be solved for a0 = 11, a1 = 9.25, and a2 = –2.5. Therefore, the interpolating
polynomial is
x0 = 1 f(x0) = 3
x1 = 2 f(x1) = 6
x2 = 3 f(x2) = 19
x3 = 5 f(x3) = 99
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
a0 a1 a 2 a 3 3
a0 2a1 4a 2 8a 3 6
a0 3a1 9a 2 27 a 3 19
a0 5a1 25 a 2 125 a 3 99
These can be solved for a0 = 4, a1 = –1, a2 = –1, and a3 = 1. Therefore, the interpolating
polynomial is
f(x) = 4 – x – x2 + x3
Option Explicit
Sub Newt()
Dim n As Integer, i As Integer
Dim yint(10) As Double, x(10) As Double, y(10) As Double
Dim ea(10) As Double, xi As Double
Sheets("Sheet1").Select
Range("a5").Select
n = ActiveCell.Row
Selection.End(xlDown).Select
n = ActiveCell.Row - n
Range("a5").Select
For i = 0 To n
x(i) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
y(i) = ActiveCell.Value
ActiveCell.Offset(1, -1).Select
Next i
Range("e3").Select
xi = ActiveCell.Value
Call Newtint(x, y, n, xi, yint, ea)
Range("d5:f25").ClearContents
Range("d5").Select
For i = 0 To n
ActiveCell.Value = i
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = yint(i)
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = ea(i)
ActiveCell.Offset(1, -2).Select
Next i
Range("a5").Select
End Sub
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
For i = 0 To n - j
fdd(i, j) = (fdd(i + 1, j - 1) - fdd(i, j - 1)) / (x(i + j) - x(i))
Next i
Next j
xterm = 1#
yint(0) = fdd(0, 0)
For order = 1 To n
xterm = xterm * (xi - x(order - 1))
yint2 = yint(order - 1) + fdd(0, order) * xterm
ea(order - 1) = yint2 - yint(order - 1)
yint(order) = yint2
Next order
End Sub
For those who are using MATLAB, here is an M-file that implements Newton interpolation:
18.15 Here is the solution when the Excel VBA program from Prob. 18.14 is run for Example
18.5.
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
18.16 Here are the solutions when the program from Prob. 18.14 is run for Probs. 18.1 through
18.3.
18.17 A plot of the error can easily be added to the Excel application. Note that we plot the
absolute value of the error on a logarithmic scale. The following shows the solution for Prob.
18.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.
14
18.18
Option Explicit
Sub LagrInt()
Dim n As Integer, i As Integer, order As Integer
Dim x(10) As Double, y(10) As Double, xi As Double
Range("a5").Select
n = ActiveCell.Row
Selection.End(xlDown).Select
n = ActiveCell.Row - n
Range("a5").Select
For i = 0 To n
x(i) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
y(i) = ActiveCell.Value
ActiveCell.Offset(1, -1).Select
Next i
Range("e3").Select
order = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
xi = ActiveCell.Value
ActiveCell.Offset(2, 0).Select
ActiveCell.Value = Lagrange(x, y, order, xi)
End Sub
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
End Function
For those who are using MATLAB, here is an M-file that implements Lagrange interpolation:
n = length(x);
if length(y)~=n, error('x and y must be same length'); end
s = 0;
for i = 1:n
product = y(i);
for j = 1:n
if i ~= j
product = product*(xx-x(j))/(x(i)-x(j));
end
end
s = s+product;
end
yint = s;
18.19 The following VBA program uses cubic interpolation for all intervals:
Option Explicit
Sub TableLook()
Dim n As Integer, i As Integer
Dim yint(10) As Double, x(10) As Double, y(10) As Double
Dim ea(10) As Double, xi As Double
Range("a5").Select
n = ActiveCell.Row
Selection.End(xlDown).Select
n = ActiveCell.Row - n
Range("a5").Select
For i = 0 To n
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
x(i) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
y(i) = ActiveCell.Value
ActiveCell.Offset(1, -1).Select
Next i
Range("e4").Select
xi = ActiveCell.Value
ActiveCell.Offset(2, 0).Select
ActiveCell.Value = Interp(x, y, n, xi)
Range("a5").Select
End Sub
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
18.20
Option Explicit
Sub Splines()
Dim i As Integer, n As Integer
Dim x(7) As Double, y(7) As Double, xu As Double, yu As Double
Dim dy As Double, d2y As Double
Range("a5").Select
n = ActiveCell.Row
Selection.End(xlDown).Select
n = ActiveCell.Row - n
Range("a5").Select
For i = 0 To n
x(i) = ActiveCell.Value
ActiveCell.Offset(0, 1).Select
y(i) = ActiveCell.Value
ActiveCell.Offset(1, -1).Select
Next i
Range("e4").Select
xu = ActiveCell.Value
Call Spline(x, y, n, xu, yu, dy, d2y)
ActiveCell.Offset(2, 0).Select
ActiveCell.Value = yu
End Sub
Sub Tridiag(x, y, n, e, f, g, r)
Dim i As Integer
f(1) = 2 * (x(2) - x(0))
g(1) = x(2) - x(1)
r(1) = 6 / (x(2) - x(1)) * (y(2) - y(1))
r(1) = r(1) + 6 / (x(1) - x(0)) * (y(0) - y(1))
For i = 2 To n - 2
e(i) = x(i) - x(i - 1)
f(i) = 2 * (x(i + 1) - x(i - 1))
g(i) = x(i + 1) - x(i)
r(i) = 6 / (x(i + 1) - x(i)) * (y(i + 1) - y(i))
r(i) = r(i) + 6 / (x(i) - x(i - 1)) * (y(i - 1) - y(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.
18
Next i
e(n - 1) = x(n - 1) - x(n - 2)
f(n - 1) = 2 * (x(n) - x(n - 2))
r(n - 1) = 6 / (x(n) - x(n - 1)) * (y(n) - y(n - 1))
r(n - 1) = r(n - 1) + 6 / (x(n - 1) - x(n - 2)) * (y(n - 2) - y(n - 1))
End Sub
Sub Decomp(e, f, g, n)
Dim k As Integer
For k = 2 To n
e(k) = e(k) / f(k - 1)
f(k) = f(k) - e(k) * g(k - 1)
Next k
End Sub
Sub Substit(e, f, g, r, n, x)
Dim k As Integer
For k = 2 To n
r(k) = r(k) - e(k) * r(k - 1)
Next k
x(n) = r(n) / f(n)
For k = n - 1 To 1 Step -1
x(k) = (r(k) - g(k) * x(k + 1)) / f(k)
Next k
End Sub
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.
19
6.5453 6.4147
s 6.4147 (0.108 0.10377) 6.486726
0.11144 0.10377
15.83811 17.02738
s 6.486726 (0.108 0.10377)(0.108 0.11144) 6.487526
0.1254 0.10377
The roots problem can then be developed by setting this polynomial equal to the desired
value of 6.6 to give
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.
20
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.