0% found this document useful (0 votes)
64 views28 pages

6eSM Ch05Final

Uploaded by

터필리버스
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views28 pages

6eSM Ch05Final

Uploaded by

터필리버스
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

1

CHAPTER 5
5.1 (a) A plot indicates that roots occur at about x = –1.6 and 5.6.
8

0
-5 0 5 10
-4

-8

(b)
−1.62859
− 2.4 ± (2.4) 2 − 4(−0.6)(5.5)
x= =
2(−0.6)
5.62859
(c) First iteration:
5 + 10
xr = = 7.5
2
5.62859 − 7.5 10 − 5
εt = × 100% = 33.25% εa = × 100% = 33.33%
5.62859 10 + 5

f (5) f (7.5) = 2.5(−10.25) = −25.625

Therefore, the bracket is xl = 5 and xu = 7.5.

Second iteration:
5 + 7.5
xr = = 6.25
2
5.62859 − 6.25 7.5 − 5
εt = × 100% = 11.04% ε a = × 100% = 20.00%
5.62859 7.5 + 5

f (5) f (6.25) = 2.5(−2.9375) = −7.34375

Consequently, the new bracket is xl = 5 and xu = 6.25.

Third iteration:
5 + 6.25
xr = = 5.625
2
5.62859 − 5.625 6.25 − 5
εt = × 100% = 0.06% ε a = × 100% = 11.11%
5.62859 6.25 + 5

5.2 (a) A plot indicates that a single real root occurs at about x = 0.45.

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

0
-1 0 1
-4

-8

(b) First iteration:


0 +1
xr = = 0.5
2
1− 0
εa = × 100% = 100%
1+ 0
f (0) f (0.5) = −2.3(0.2) = −0.46

Therefore, the new bracket is xl = 0 and xu = 0.5. The process can be repeated until the approximate
error falls below 10%. As summarized below, this occurs after 5 iterations yielding a root estimate of
0.46875.

iteration xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0 1 0.5 -2.3 0.2 -0.46 100.00%
2 0 0.5 0.25 -2.3 -0.8625 1.98375 100.00%
3 0.25 0.5 0.375 -0.8625 -0.30781 0.265488 33.33%
4 0.375 0.5 0.4375 -0.30781 -0.05098 0.015691 14.29%
5 0.4375 0.5 0.46875 -0.05098 0.074878 -0.00382 6.67%

5.3 (a) A plot indicates that a single real root occurs at about x = 0.56.

0
0 0.5 1 1.5
-4

-8

(b) Bisection:
First iteration:
0.5 + 1
xr = = 0.75
2
1 − 0.5
εa = × 100% = 33.33%
1 + 0.5
f (0.5) f (0.75) = −1.21875(2.83105) = −3.45035

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

Therefore, the new bracket is xl = 0.5 and xu = 0.75. The process can be repeated until the approximate
error falls below 10%. As summarized below, this occurs after 4 iterations yielding a root estimate of
0.53125.

iteration xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0.50000 1.00000 0.75000 -1.21875 2.83105 -3.45035 33.33%
2 0.50000 0.75000 0.62500 -1.21875 1.19498 -1.45638 20.00%
3 0.50000 0.62500 0.56250 -1.21875 0.10600 -0.12918 11.11%
4 0.50000 0.56250 0.53125 -1.21875 -0.52422 0.63889 5.88%

(c) False position:


First iteration:
xl = 0.5 f(xl) = –1.21875
xu = 1 f(xu) = 5
5(0.5 − 1)
xr = 1 − = 0.59799
− 1.21875 − 5
f (0.5) f (0.59799) = −1.2175(0.75057) = −0.91475

Therefore, the bracket is xl = 0.5 and xu = 0.59799.

Second iteration:
xl = 0.5 f(xl) = –1.21875
xu = 0.59799 f(xu) = 0.75057
0.75057(0.5 − 0.59799)
x r = 0.59799 − = 0.56064
− 1.21875 − 0.75057
0.56064 − 0.59799
εa = × 100% = 6.661%
0.56064

The process can be repeated until the approximate error falls below 0.2%. As summarized below, this
occurs after 4 iterations yielding a root estimate of 0.55705.

iteration xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 0.5 1.00000 -1.21875 5.00000 0.59799 0.75057 -0.91475
2 0.5 0.59799 -1.21875 0.75057 0.56064 0.07024 -0.08561 6.661%
3 0.5 0.56064 -1.21875 0.07024 0.55734 0.00610 -0.00744 0.593%
4 0.5 0.55734 -1.21875 0.00610 0.55705 0.00053 -0.00064 0.051%

5.4 (a) The graph indicates that roots are located at about –0.5, 2 and 4.7.
40

20

0
-2 0 2 4 6
-20

(b) Using bisection, the first iteration is

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

−1 + 0
xr = = −0.5
2
f (−1) f (−0.5) = 29(2.125) = 61.625

Therefore, the root is in the second interval and the lower guess is redefined as xl = –0.5. The second
iteration is

−0.5 + 0
xr = = −0.25
2
− 0.25 − (−0.5)
εa = 100% = 100%
− 0.25
f (−0.5) f (−0.25) = 2.125(−6.76563) = −14.37695

Consequently, the root is in the first interval and the upper guess is redefined as xu = –0.25. All the
iterations are displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) εa


1 -1.0 29.00000 0 -13.00000 -0.5 2.12500 100.00%
2 -0.5 2.12500 0 -13.00000 -0.25 -6.76563 100.00%
3 -0.5 2.12500 -0.25 -6.76563 -0.375 -2.66992 33.33%
4 -0.5 2.12500 -0.375 -2.66992 -0.43750 -0.36206 14.29%
5 -0.50000 2.12500 -0.438 -0.36206 -0.46875 0.85880 6.67%
6 -0.46875 0.85880 -0.43750 -0.36206 -0.45313 0.24273 3.45%
7 -0.45313 0.24273 -0.43750 -0.36206 -0.44531 -0.06107 1.75%
8 -0.45313 0.24273 -0.44531 -0.06107 -0.44922 0.09048 0.87%

Thus, after eight iterations, we obtain a root estimate of −0.44922 with an approximate error of 0.87%,
which is below the stopping criterion of 1%.

(c) Using false position, the first iteration is

−13(−1 − 0)
xr = 0 − = −0.30952
29 − (−13)
f (−1) f (−0.30952) = 29(−4.90027) = −142.10775

Therefore, the root is in the first interval and the upper guess is redefined as xu = –0.30952. The second
iteration is

−4.90027(−1 − (−0.30952))
x r = −0.30952 − = −0.40933
29 − (−4.90027)
− 0.40933 − (−0.30952)
εa = 100% = 24.383%
− 0.40933
f (−1) f (−0.40933) = 29(−1.42411) = −41.29925

Consequently, the root is in the first interval and the upper guess is redefined as xu = –0.40933. All the
iterations are displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) εa


1 -1 29.00 0 -13 -0.30952 -4.90027
2 -1 29.00 -0.30952 -4.90027 -0.40933 -1.42411 24.383%

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

3 -1 29.00 -0.40933 -1.42411 -0.43698 -0.38199 6.327%


4 -1 29.00 -0.43698 -0.38199 -0.44430 -0.10024 1.647%
5 -1 29.00 -0.44430 -0.10024 -0.44621 -0.02615 0.429%

Therefore, after five iterations we obtain a root estimate of –0.44621 with an approximate error of
0.429%, which is below the stopping criterion of 1%.

5.5 A graph indicates that a nontrivial root (i.e., nonzero) is located at about 0.93.

0.5

0
0 0.5 1 1.5
-0.5

-1

-1.5

Using bisection, the first iteration is

0.5 + 1
xr = = 0.75
2
f (0.5) f (0.75) = 0.354426(0.2597638) = 0.092067

Therefore, the root is in the second interval and the lower guess is redefined as xl = 0.75. The second
iteration is

0.75 + 1
xr = = 0.875
2
0.875 − 0.75
εa = 100% = 14.29%
0.875
f (0.75) f (0.875) = 0.259764(0.0976216) = 0.025359

Because the product is positive, the root is in the second interval and the lower guess is redefined as xl
= 0.875. All the iterations are displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) εa


1 0.5 0.354426 1 -0.158529 0.75 0.2597638
2 0.75 0.259764 1 -0.158529 0.875 0.0976216 14.29%
3 0.875 0.097622 1 -0.158529 0.9375 -0.0178935 6.67%
4 0.875 0.097622 0.9375 -0.0178935 0.90625 0.0429034 3.45%
5 0.90625 0.042903 0.9375 -0.0178935 0.921875 0.0132774 1.69%

Consequently, after five iterations we obtain a root estimate of 0.921875 with an approximate error of
1.69%, which is below the stopping criterion of 2%. The result can be checked by substituting it into
the original equation to verify that it is close to zero.

f ( x) = sin( x) − x 3 = sin(0.921875) − 0.921875 3 = 0.0132774

5.6 (a) A graph of the function indicates a positive real root at approximately x = 1.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.
6

10

0
-2 -1 0 1 2
-10

-20

(b) Using bisection, the first iteration is

0.5 + 2
xr = = 1.25
2
2 − 0.5
εa = 100% = 60%
2 + 0.5
f (0.5) f (1.25) = −3.47259(0.19257) = −0.66873

Therefore, the root is in the first interval and the upper guess is redefined as xu = 1.25. The second
iteration is

0.5 + 1.25
xr = = 0.875
2
0.875 − 1.25
εa = 100% = 42.86%
0.875
f (0.5) f (0.875) = −3.47259(−1.23413) = 4.28561

Consequently, the root is in the second interval and the lower guess is redefined as xl = 0.875. All the
iterations are displayed in the following table:

i xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0.50000 2.00000 1.25000 -3.47259 0.19257 -0.66873
2 0.50000 1.25000 0.87500 -3.47259 -1.23413 4.28561 42.86%
3 0.87500 1.25000 1.06250 -1.23413 -0.4575 0.56461 17.65%

Thus, after three iterations, we obtain a root estimate of 1.0625 with an approximate error of 17.65%.

(c) Using false position, the first iteration is

2.07259(0.5 − 2)
xr = 2 − = 1.43935
− 3.47259 − 2.07259
f (0.5) f (1.43935) = −3.47259(0.75678) = −2.62797

Therefore, the root is in the first interval and the upper guess is redefined as xu = 1.43935. The second
iteration is

0.75678(0.5 − 1.43935)
x r = 1.43935 − = 1.27127
− 3.47259 − 0.75678
1.27127 − 1.43935
εa = 100% = 13.222%
1.27127
f (0.5) f (1.27127) = −3.47259(0.26007) = −0.90312

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

Consequently, the root is in the first interval and the upper guess is redefined as xu = 1.27127. All the
iterations are displayed in the following table:

iteration xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 0.5 2.00000 -3.47259 2.07259 1.43935 0.75678 -2.62797
2 0.5 1.43935 -3.47259 0.75678 1.27127 0.26007 -0.90312 13.222%
3 0.5 1.27127 -3.47259 0.26007 1.21753 0.08731 -0.30319 4.414%

After three iterations we obtain a root estimate of 1.21753 with an approximate error of 4.414%.

5.7 (a) (0.8 − 0.3 x) = 0


0.8
x= = 2.666667
0.3

(b) The graph of the function indicates a root between x = 2 and 3. Note that the shape of the curve
suggests that it may be ill-suited for solution with the false-position method (refer to Fig. 5.14)

6
4
2
0
-2 0 1 2 3 4 5

(c) Using false position, the first iteration is

−0.03333(1 − 3)
xr = 3 − = 2.875
0.5 − (−0.03333)
2.66667 − 2.875
εt = 100% = 7.81%
2.66667
f (1) f (2.875) = 0.5(−0.02174) = −0.01087

Therefore, the root is in the first interval and the upper guess is redefined as xu = 2.875. The second
iteration is

−0.03333(1 − 2.875)
x r = 2.875 − = 2.79688
0.5 − (−0.03333)
2.79688 − 2.875
εa = 100% = 2.793%
2.79688
2.66667 − 2.79688
εt = 100% = 4.88%
2.66667
f (1) f (2.79688) = 0.5(−0.01397) = −0.00698

Consequently, the root is in the first interval and the upper guess is redefined as xu = 2.79688. All the
iterations are displayed in the following table:

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa εt

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

1 1 3.00000 0.5 -0.03333 2.87500 -0.02174 -0.01087 7.81%


2 1 2.87500 0.5 -0.02174 2.79688 -0.01397 -0.00698 2.793% 4.88%
3 1 2.79688 0.5 -0.01397 2.74805 -0.00888 -0.00444 1.777% 3.05%

Therefore, after three iterations we obtain a root estimate of 2.74805 with an approximate error of
1.777%. Note that the true error is greater than the approximate error. This is not good because it
means that we could stop the computation based on the erroneous assumption that the true error is at
least as good as the approximate error. This is due to the slow convergence that results from the
function’s shape.

5.8 The square root of 18 can be set up as a roots problem by determining the positive root of the function

f ( x) = x 2 − 18 = 0

Using false position, the first iteration is

7(4 − 5)
xr = 5 − = 4.22222
−2−7
f (4) f (4.22222) = −2(−0.17284) = 0.34568

Therefore, the root is in the second interval and the lower guess is redefined as xl = 4.22222. The
second iteration is

7(4.22222 − 5)
x r = 4.22222 − = 4.24096
− 0.17284 − 7
4.24096 − 4.22222
εa = 100% = 0.442%
4.24096

Thus, the computation can be stopped after just two iterations because 0.442% < 0.5%. Note that the
true value is 4.2426. The technique converges so quickly because the function is very close to being a
straight line in the interval between the guesses as in the plot of the function shown below.
10

0
4 4.5 5
-5

5.9 A graph of the function indicates a positive real root at approximately x = 3.7.

10

0
0 1 2 3 4 5

-10

Using false position, the first iteration is

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

10.43182(0 − 5)
xr = 5 − = 1.62003
− 5 − 10.43182
f (0) f (1.62003) = −5(−4.22944) = 21.147

Therefore, the root is in the second interval and the lower guess is redefined as xl = 1.62003. The
remaining iterations are summarized below

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 0 5.00000 -5 10.43182 1.62003 -4.22944 21.14722
2 1.62003 5.00000 -4.2294 10.43182 2.59507 -4.72984 20.00459 37.573%
3 2.59507 5.00000 -4.7298 10.43182 3.34532 -2.14219 10.13219 22.427%
4 3.34532 5.00000 -2.1422 10.43182 3.62722 -0.69027 1.47869 7.772%
5 3.62722 5.00000 -0.6903 10.43182 3.71242 -0.19700 0.13598 2.295%
6 3.71242 5.00000 -0.197 10.43182 3.73628 -0.05424 0.01069 0.639%

The final result, xr = 3.73628, can be checked by substituting it into the original function to yield a
near-zero result,

f (3.73628) = (3.73628) 2 cos 3.73628 − 5 = −0.05424

5.10 Using false position, the first iteration is

7(4.5 − 6)
xr = 6 − = 5.01754
− 3.6875 − 7
f (4.5) f (5.01754) = −3.6875(−1.00147) = 3.69294

Therefore, the root is in the second interval and the lower guess is redefined as xu = 5.01754. The true
error can be computed as

5.60979 − 5.01754
εt = 100% = 10.56%
5.60979

The second iteration is

7(5.01754 − 6)
xr = 6 − = 5.14051
− 1.00147 − 7
5.60979 − 5.14051
εt = 100% = 8.37%
5.60979
5.14051 − 5.01754
εa = 100% = 2.392%
5.14051
f (5.01754) f (5.14051) = −1.00147(−1.06504) = 1.06661

Consequently, the root is in the second interval and the lower guess is redefined as xu = 5.14051. All
the iterations are displayed in the following table:

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa, % εt, %


1 4.50000 6 -3.68750 7.00000 5.01754 -1.00147 3.69294 10.56
2 5.01754 6 -1.00147 7.00000 5.14051 -1.06504 1.06661 2.392 8.37
3 5.14051 6 -1.06504 7.00000 5.25401 -1.12177 1.19473 2.160 6.34

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

4 5.25401 6 -1.12177 7.00000 5.35705 -1.07496 1.20586 1.923 4.51


5 5.35705 6 -1.07496 7.00000 5.44264 -0.90055 0.96805 1.573 2.98
6 5.44264 6 -0.90055 7.00000 5.50617 -0.65919 0.59363 1.154 1.85
7 5.50617 6 -0.65919 7.00000 5.54867 -0.43252 0.28511 0.766 1.09

Notice that the results have the undesirable feature that the true error is greater than the approximate
error. This is not good because it means that we could stop the computation based on the erroneous
assumption that the true error is at least as good as the approximate error. This is due to the slow
convergence that results from the function’s shape as shown in the following plot (recall Fig. 5.14).

8
6
4
2
0
-2 4 4.5 5 5.5 6
-4
-6

5.11 (a)

x r = (80)1 / 3.5 = 3.497357

(b) Here is a summary of the results obtained with false position to the point that the approximate error
falls below the stopping criterion of 2.5%:

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 2 5 -68.68629 199.5085 2.76832 -44.70153 3070.382
2 2.768318 5 -44.70153 199.5085 3.17682 -22.85572 1021.686 12.859%
3 3.176817 5 -22.85572 199.5085 3.36421 -10.16193 232.258 5.570%
4 3.364213 5 -10.16193 199.5085 3.44349 -4.229976 42.985 2.302%

5.12 A plot of the function indicates a maximum at about 0.9.

10

0
-0.5 0 0.5 1 1.5
-5

-10

In order to determine the maximum with a root location technique, we must first differentiate the
function to yield

f ' ( x) = −12 x 5 − 6.4 x 3 + 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.
11

The root of this function represents an extremum. Using bisection and the recommended initial guesses
gives:

i xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0.00000 1.00000 0.50000 12.00000 10.82500 129.9000 100.00%
2 0.50000 1.00000 0.75000 10.82500 6.45234 69.8466 33.33%
3 0.75000 1.00000 0.87500 6.45234 1.55759 10.0501 14.29%
4 0.87500 1.00000 0.93750 1.55759 -1.96379 -3.0588 6.67%
5 0.87500 0.93750 0.90625 1.55759 -0.09884 -0.1539 3.45%

The maximum can be determined by substituting the root into the original equation to give

f (0.90625) = −2(0.90625) 6 − 1.6(0.90625) 4 + 12(0.90625) + 1 = 9.68783

5.13 The correct mass can be determined by finding the root of

f ( m) =
9.8m
15
( )
1 − e −(15 / m)9 − 35 = 0

Here are the results of using false position with initial guesses of 50 and 70 kg:

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 50 70.00000 -4.52871 4.085733 60.51423 0.288464 -1.30637
2 50 60.51423 -4.52871 0.288464 59.88461 0.018749 -0.08491 1.051%
3 50 59.88461 -4.52871 0.018749 59.84386 0.001212 -0.00549 0.068%

Thus, after 3 iterations, a value of 59.84386 kg is determined with an approximate error of 0.068%.
This result can be verified by substituting it into the equation for velocity to give

v=
9.8(59.84386)
15
( )
1 − e −(15 / 59.84386)9 = 35.00121
m
s

5.14 [First printing errata: the initial guesses should be xl = 3 and xu = 5].

The function to evaluate is

f (c ) =
9.81(80)
c
( )
1 − e −( c / 80) 4 − 36 = 0

The first iteration is

3+5
xr = =4
2
f (3) f (4) = 0.438793(−1.28057) = −0.19086

Therefore, the root is in the first interval and the upper guess is redefined as xu = 4. The second
iteration is

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

3+ 4
xr = = 3.5
2
3.5 − 4
εa = 100% = 14.29%
3.5
f (3) f (3.5) = 0.438793(−0.0016771) = −0.00074

Therefore, the root is in the first interval and the upper bound is redefined as xu = 3.5. The remaining
iterations are displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) |εa|


1 3 0.43879 5 -1.28057 4 -0.43497
2 3 0.43879 4 -0.43497 3.5 -0.00168 14.29%
3 3 0.43879 3.5 -0.00168 3.25 0.21765 7.69%
4 3.25 0.21765 3.5 -0.00168 3.375 0.10776 3.70%
5 3.375 0.10776 3.5 -0.00168 3.4375 0.05299 1.82%

Thus, after five iterations, we obtain a root estimate of 3.4375 with an approximate error of 1.82%.

5.15 Solve for the reactions:

R1=265 lbs. R2= 285 lbs.

Write beam equations:


x
M + (16.667 x 2 ) − 265 x = 0
0<x<3 3
(1) M = 265 x − 5.5555556 x 3
x−3 2
M + 100( x − 3)( ) + 150( x − (3)) − 265 x = 0
3<x<6 2 3
(2) M = −50 x + 415 x − 150
2

2
M = 150( x − (3)) + 300( x − 4.5) − 265 x
6<x<10 3
(3) M = −185 x + 1650
M + 100(12 − x ) = 0
10<x<12
(4) M = 100 x − 1200

A plot of these equations can be generated:

1000

500

0
0 4 8 12
-500

0<x<3 3<x<6 6<x<10 10<x<12

Combining Equations:

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

Because the curve crosses the axis between 6 and 10, use (3).

(3) M = −185 x + 1650

Set x L = 6; xU = 10

M ( x L ) = 540 x L + xU
xr = =8
M ( xU ) = −200 2
M ( x R ) = 170 → replaces x L
M ( x L ) = 170 8 + 10
xr = =9
M ( xU ) = −200 2
M ( x R ) = −15 → replaces xU
M ( x L ) = 170 8+9
xr = = 8.5
M ( xU ) = −15 2
M ( x R ) = 77.5 → replaces x L
M ( x L ) = 77.5 8.5 + 9
xr = = 8.75
M ( xU ) = −15 2
M ( x R ) = 31.25 → replaces x L
M ( x L ) = 31.25 8.75 + 9
xr = = 8.875
M ( xU ) = −15 2
M ( x R ) = 8.125 → replaces x L
M ( x L ) = 8.125 8.875 + 9
xr = = 8.9375
M ( xU ) = −15 2
M ( x R ) = −3.4375 → replaces xU
M ( x L ) = 8.125 8.875 + 8.9375
xr = = 8.90625
M ( xU ) = −3.4375 2
M ( x R ) = 2.34375 → replaces x L
M ( x L ) = 2.34375 8.90625 + 8.9375
xr = = 8.921875
M ( xU ) = −3.4375 2
M ( x R ) = −0.546875 → replaces xU
M ( x L ) = 2.34375 8.90625 + 8.921875
xr = = 8.9140625
M ( xU ) = −0.546875 2
M ( x R ) = 0.8984 Therefore, x = 8.91 feet

5.16 (a) The function to be evaluated is

400
f ( y) = 1 − (3 + y )
9.81(3 y + y 2 / 2) 3

A graph of the function indicates a positive real root at approximately 1.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.
14

10
0
-10 0 0.5 1 1.5 2 2.5

-20
-30
-40

(b) Using bisection, the first iteration is

0.5 + 2.5
xr = = 1.5
2
f (0.5) f (1.5) = −32.2582(−0.030946) = 0.998263

Therefore, the root is in the second interval and the lower guess is redefined as xl = 1.5. The second
iteration is

1.5 + 2.5
xr = =2
2
2 − 1.5
εa = 100% = 25%
2
f (1.5) f (2) = −0.030946(0.601809) = −0.018624

Therefore, the root is in the first interval and the upper guess is redefined as xu = 2. All the iterations
are displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) εa


1 0.5 −32.2582 2.5 0.813032 1.5 −0.030946
2 1.5 −0.03095 2.5 0.813032 2 0.601809 25.00%
3 1.5 −0.03095 2 0.601809 1.75 0.378909 14.29%
4 1.5 −0.03095 1.75 0.378909 1.625 0.206927 7.69%
5 1.5 −0.03095 1.625 0.206927 1.5625 0.097956 4.00%
6 1.5 −0.03095 1.5625 0.097956 1.53125 0.036261 2.04%
7 1.5 −0.03095 1.53125 0.036261 1.515625 0.003383 1.03%
8 1.5 −0.03095 1.515625 0.003383 1.5078125 −0.013595 0.52%

After eight iterations, we obtain a root estimate of 1.5078125 with an approximate error of 0.52%.

(c) Using false position, the first iteration is

0.81303(0.5 − 2.5)
x r = 2.5 − = 2.45083
− 32.2582 − 0.81303
f (0.5) f (2.45083) = −32.25821(0.79987) = −25.80248

Therefore, the root is in the first interval and the upper guess is redefined as xu = 2.45083. The second
iteration is

0.79987(0.5 − 2.45083)
x r = 2.45083 − = 2.40363
− 32.25821 − 0.79987

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

2.40363 − 2.45083
εa = 100% = 1.96%
2.40363
f (0.5) f (2.40363) = −32.2582(0.78612) = −25.35893

The root is in the first interval and the upper guess is redefined as xu = 2.40363. All the iterations are
displayed in the following table:

i xl f(xl) xu f(xu) xr f(xr) εa


1 0.5 −32.2582 2.50000 0.81303 2.45083 0.79987
2 0.5 −32.2582 2.45083 0.79987 2.40363 0.78612 1.96%
3 0.5 −32.2582 2.40363 0.78612 2.35834 0.77179 1.92%
4 0.5 −32.2582 2.35834 0.77179 2.31492 0.75689 1.88%
5 0.5 −32.2582 2.31492 0.75689 2.27331 0.74145 1.83%
6 0.5 −32.2582 2.27331 0.74145 2.23347 0.72547 1.78%
7 0.5 −32.2582 2.23347 0.72547 2.19534 0.70900 1.74%
8 0.5 −32.2582 2.19534 0.70900 2.15888 0.69206 1.69%
9 0.5 −32.2582 2.15888 0.69206 2.12404 0.67469 1.64%
10 0.5 −32.2582 2.12404 0.67469 2.09077 0.65693 1.59%

After ten iterations we obtain a root estimate of 2.09077 with an approximate error of 1.59%. Thus,
after ten iterations, the false position method is converging at a very slow pace and is still far from the
root in the vicinity of 1.5 that we detected graphically.

Discussion: This is a classic example of a case where false position performs poorly and is inferior to
bisection. Insight into these results can be gained by examining the plot that was developed in part (a).
This function violates the premise upon which false position was based−that is, if f(xu) is much closer
to zero than f(xl), then the root is closer to xu than to xl (recall Figs. 5.12 and 5.14). Because of the
shape of the present function, the opposite is true.

5.17 The equation to be solved is

⎛π ⎞
f (h) = πRh 2 − ⎜ ⎟h 3 − V
⎝3⎠

Here is a summary of the results obtained with three iterations of false position:

i xl xu f(xl) f(xu) xr f(xr) f(xl)×f(xr) εa


1 0 3.00000 -30 26.54867 1.59155 -10.3485 310.45424
2 1.59155 3.00000 -10.348 26.54867 1.98658 -1.01531 10.50688 19.885%
3 1.98658 3.00000 -1.0153 26.54867 2.02390 -0.07591 0.07708 1.844%

The result can be verified by substituting it into the volume equation to give

3(3) − 2.0239
V = π (2.0239) 2 = 29.92409
3

5.18 (a) Equation (5.5) can be used to determine the number of iterations

⎛ Δx 0 ⎞
n = log 2 ⎜ ⎟ = log 2 ⎛⎜ 40 ⎞⎟ = 9.6439
⎜ E a,d ⎟ ⎝ 0.05 ⎠
⎝ ⎠

which can be rounded up to 10 iterations.

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

(b) Here is an M-file that evaluates the temperature in oC using 11 iterations of bisection based on a
given value of the oxygen saturation concentration in freshwater:

function TC = TempEval(osf)
% function to evaluate the temperature in degrees C based
% on the oxygen saturation concentration in freshwater (osf).
xl = 0 + 273.15;
xu = 40 + 273.15;
if fTa(xl,osf)*fTa(xu,osf)>0 %if guesses do not bracket
error('no bracket') %display an error message and terminate
end
xr = xl;
for i = 1:10
xrold = xr;
xr = (xl + xu)/2;
if xr ~= 0, ea = abs((xr - xrold)/xr) * 100; end
test = fTa(xl,osf)*fTa(xr,osf);
if test < 0
xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
end
TC = xr - 273.15;

function f = fTa(Ta, osf)


f = -139.34411 + 1.575701e5/Ta - 6.642308e7/Ta^2;
f = f + 1.2438e10/Ta^3 - 8.621949e11/Ta^4;
f = f - log(osf);

The function can be used to evaluate the test cases:

>> TempEval(8)

ans =
26.7578

>> TempEval(10)

ans =
15.3516

>> TempEval(12)

ans =
7.4609

Note that these values can be compared with the true values to verify that the errors are less than 0.05:

osf Approximation Exact Error


8 26.75781 26.78017 0.0224
10 15.35156 15.38821 0.0366
12 7.46094 7.46519 0.0043

5.19 The function to be solved is

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

(4 + x)
f ( x) = − 0.016 = 0
(42 − 2 x) 2 (28 − x)

(a) A plot of the function indicates a root at about x = 16.

0.8
0.6
0.4
0.2
0
-0.2 0 5 10 15 20

(b) The shape of the function indicates that false position would be a poor choice (recall Fig. 5.14).
Bisection with initial guesses of 0 and 20 can be used to determine a root of 15.85938 after 8 iterations
with εa = 0.493%. Note that false position would have required 68 iterations to attain comparable
accuracy.

i xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0 20 10 -0.01592 -0.01439 0.000229 100.000%
2 10 20 15 -0.01439 -0.00585 8.42E-05 33.333%
3 15 20 17.5 -0.00585 0.025788 -0.00015 14.286%
4 15 17.5 16.25 -0.00585 0.003096 -1.8E-05 7.692%
5 15 16.25 15.625 -0.00585 -0.00228 1.33E-05 4.000%
6 15.625 16.25 15.9375 -0.00228 0.000123 -2.8E-07 1.961%
7 15.625 15.9375 15.78125 -0.00228 -0.00114 2.59E-06 0.990%
8 15.78125 15.9375 15.85938 -0.00114 -0.00052 5.98E-07 0.493%

5.20 This problem can be solved by determining the root of the derivative of the elastic curve

dy
dx
=0=
w0
120 EIL
(
− 5 x 4 + 6 L2 x 2 − L4 )
Therefore, after substituting the parameter values, we must determine the root of

f ( x) = −5 x 4 + 2,160,000 x 2 − 1.296 × 1011 = 0

A plot of the function indicates a root at about x = 270.

2E+11
1E+11
0
-1E+11 0 100 200 300 400 500 600
-2E+11

Bisection can be used to determine the root. Here are the first few iterations:

i xl xu xr f(xl) f(xr) f(xl)×f(xr) εa


1 0 500 250 -1.3E+11 -1.4E+10 1.83E+21
2 250 500 375 -1.4E+10 7.53E+10 -1.1E+21 33.33%
3 250 375 312.5 -1.4E+10 3.37E+10 -4.8E+20 20.00%

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

4 250 312.5 281.25 -1.4E+10 9.97E+09 -1.4E+20 11.11%


5 250 281.25 265.625 -1.4E+10 -2.1E+09 2.95E+19 5.88%

After 20 iterations, the root is determined as x = 268.328. This value can be substituted into Eq.
(P8.18) to compute the maximum deflection as

2.5
y= (−(268.328) 5 + 720,000(268.328) 3 − 1.296 × 1011 (268.328)) = −0.51519
120(50,000)30,000(600)

5.21 The solution can be formulated as

i (1 + i ) 6
f (i ) = 25,000 − 5,500
(1 + i ) 6 − 1

A plot of this function suggests a root at about 0.086:


500

0
0 0.02 0.04 0.06 0.08 0.1
-500

-1000

-1500

A numerical method can be used to determine that the root is 0.085595.

5.22 (a) The solution can be formulated as

(
f (t ) = 1.2 75,000e −0.045t + 100,000 − ) 300,000
1 + 29e −0.08t

A plot of this function suggests a root at about 40:


300000
200000
100000
0
-100000 0 20 40 60 80 100

-200000

(b) The false-position method can be implemented with the results summarized as

i tl tu f(tl) f(tu) tr f(tr) f(tl)×f(tr) εa


1 0 100.0000 200000 -176110 53.1760 -84245 -1.685E+10
2 0 53.1760 200000 -84245 37.4156 14442.8 2.889E+09 42.123%
3 37.4156 53.1760 14443 -84245 39.7221 -763.628 -1.103E+07 5.807%
4 37.4156 39.7221 14443 -763.628 39.6063 3.545288 5.120E+04 0.292%
5 39.6063 39.7221 4 -763.628 39.6068 0.000486 1.724E-03 0.001%

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

(c) The modified secant method (with δ = 0.01) can be implemented with the results summarized as

i ti f(ti) δti ti+δti f(ti+δti) f′(ti) εa


0 50 -66444.8 0.50000 50.5 -69357.6 -5825.72
1 38.5946 6692.132 0.38595 38.98053 4143.604 -6603.33 29.552%
2 39.6080 -8.14342 0.39608 40.00411 -2632.32 -6625.36 2.559%
3 39.6068 -0.00345 0.39607 40.00287 -2624.09 -6625.35 0.003%

For both parts (b) and (c), the root is determined to be t = 39.6068. At this time, the ratio of the
suburban to the urban population is 135,142.5/112,618.7 = 1.2.

5.23 Here is a VBA program to implement the bisection function (Fig. 5.10) in a user-friendly format:

Option Explicit

Sub TestBisect()
Dim imax As Integer, iter As Integer
Dim x As Double, xl As Double, xu As Double
Dim es As Double, ea As Double, xr As Double
Dim root As Double
'input information from the user
Sheets("Sheet1").Select
Range("b4").Select
xl = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
xu = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
es = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
imax = ActiveCell.Value
Range("b4").Select
If f(xl) * f(xu) < 0 Then
'if the initial guesses are valid, implement bisection
'and display results
root = Bisect(xl, xu, es, imax, xr, iter, ea)
MsgBox "The root is: " & root
MsgBox "Iterations: " & iter
MsgBox "Estimated error: " & ea
MsgBox "f(xr) = " & f(xr)
Else
'if the initial guesses are invalid,
'display an error message
MsgBox "No sign change between initial guesses"
End If
End Sub

Function Bisect(xl, xu, es, imax, xr, iter, ea)


Dim xrold As Double, test As Double
iter = 0
Do
xrold = xr
'determine new root estimate
xr = (xl + xu) / 2
iter = iter + 1
'determine approximate error
If xr <> 0 Then
ea = Abs((xr - xrold) / xr) * 100
End If
'determine new bracket

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

test = f(xl) * f(xr)


If test < 0 Then
xu = xr
ElseIf test > 0 Then
xl = xr
Else
ea = 0
End If
'terminate computation if stopping criterion is met
'or maximum iterations are exceeded
If ea < es Or iter >= imax Then Exit Do
Loop
Bisect = xr
End Function

Function f(c)
f = 9.8 * 68.1 / c * (1 - Exp(-(c / 68.1) * 10)) - 40
End Function

For Example 5.3, the Excel worksheet used for input looks like:

The program yields a root of 14.78027 after 12 iterations. The approximate error at this point is
6.6×10−3 %. These results are all displayed as message boxes. For example, the solution check is
displayed as

5.24 Here is a VBA program to implement the bisection function that minimizes function evaluations (Fig.
5.11) in a user-friendly program:

Option Explicit

Sub TestBisectMin()
Dim imax As Integer, iter As Integer
Dim x As Double, xl As Double, xu As Double
Dim es As Double, ea As Double, xr As Double
Dim root As Double
'input information from the user
Sheets("Sheet1").Select
Range("b4").Select
xl = ActiveCell.Value
ActiveCell.Offset(1, 0).Select

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.
21

xu = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
es = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
imax = ActiveCell.Value
Range("b4").Select
If f(xl) * f(xu) < 0 Then
'if the initial guesses are valid, implement bisection
'and display results
root = BisectMin(xl, xu, es, imax, xr, iter, ea)
MsgBox "The root is: " & root
MsgBox "Iterations: " & iter
MsgBox "Estimated error: " & ea
MsgBox "f(xr) = " & f(xr)
Else
'if the initial guesses are invalid,
'display an error message
MsgBox "No sign change between initial guesses"
End If
End Sub

Function BisectMin(xl, xu, es, imax, xr, iter, ea)


Dim xrold As Double, test As Double, fl As Double, fr As Double
iter = 0
fl = f(xl)
Do
xrold = xr
'determine new root estimate
xr = (xl + xu) / 2
fr = f(xr)
iter = iter + 1
'determine approximate error
If xr <> 0 Then
ea = Abs((xr - xrold) / xr) * 100
End If
'determine new bracket
test = fl * fr
If test < 0 Then
xu = xr
ElseIf test > 0 Then
xl = xr
fl = fr
Else
ea = 0
End If
'terminate computation if stopping criterion is met
'or maximum iterations are exceeded
If ea < es Or iter >= imax Then Exit Do
Loop
BisectMin = xr
End Function

Function f(x)
f = x ^ 10 - 1
End Function

For Example 5.6, the Excel worksheet used for input looks like:

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.
22

After 14 iterations, the program yields

The number of function evaluations per iteration can be determined by inspecting the code. After the
initial evaluation of the function at the lower bound (fl = f(xl)), there is a single additional
evaluation per iteration (fr = f(xr)). Therefore, the number of function evaluations is equal to the
number of iterations plus 1. In contrast, the pseudocode from Fig. 5.10 which does not attempt to
minimize function results in function evaluations equaling twice the iterations. Thus, the code in Fig.
5.11 should execute about twice as fast as Fig. 5.10.

5.25 Here is a VBA program to implement false position that is similar in structure to the bisection
algorithm outlined in Fig. 5.10:

Option Explicit

Sub TestFP()
Dim imax As Integer, iter As Integer
Dim x As Double, xl As Double, xu As Double
Dim es As Double, ea As Double, xr As Double
Dim root As Double
'input information from the user
Sheets("Sheet1").Select
Range("b4").Select
xl = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
xu = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
es = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
imax = ActiveCell.Value
Range("b4").Select
If f(xl) * f(xu) < 0 Then
'if the initial guesses are valid, implement bisection
'and display results
root = FalsePos(xl, xu, es, imax, xr, iter, ea)
MsgBox "The root is: " & root
MsgBox "Iterations: " & iter
MsgBox "Estimated error: " & ea
MsgBox "f(xr) = " & f(xr)
Else
'if the initial guesses are invalid,

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.
23

'display an error message


MsgBox "No sign change between initial guesses"
End If
End Sub

Function FalsePos(xl, xu, es, imax, xr, iter, ea)


Dim xrold As Double, test As Double
iter = 0
Do
xrold = xr
'determine new root estimate
xr = xu - f(xu) * (xl - xu) / (f(xl) - f(xu))
iter = iter + 1
'determine approximate error
If xr <> 0 Then
ea = Abs((xr - xrold) / xr) * 100#
End If
'determine new bracket
test = f(xl) * f(xr)
If (test < 0) Then
xu = xr
ElseIf (test > 0) Then
xl = xr
Else
ea = 0#
End If
'terminate computation if stopping criterion is met
'or maximum iterations are exceeded
If ea < es Or iter >= imax Then Exit Do
Loop
FalsePos = xr
End Function

Function f(c)
f = 9.8 * 68.1 / c * (1 - Exp(-(c / 68.1) * 10)) - 40
End Function

For Example 5.5, the Excel worksheet used for input looks like:

The program yields a root of 14.78036 after 4 iterations. The approximate error at this point is
9.015×10−3 %. These results are all displayed as message boxes. For example, the solution check is
displayed as

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.
24

5.26 Here is a VBA Sub procedure to implement the false position method which minimizes function
evaluations. It is set up to evaluate Example 5.6.

Option Explicit

Sub TestFP()
Dim imax As Integer, iter As Integer
Dim x As Double, xl As Double, xu As Double
Dim es As Double, ea As Double, xr As Double
Dim root As Double
'input information from the user
Sheets("Sheet1").Select
Range("b4").Select
xl = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
xu = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
es = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
imax = ActiveCell.Value
Range("b4").Select
If f(xl) * f(xu) < 0 Then
'if the initial guesses are valid, implement bisection
'and display results
root = FalsePosMin(xl, xu, es, imax, xr, iter, ea)
MsgBox "The root is: " & root
MsgBox "Iterations: " & iter
MsgBox "Estimated error: " & ea
MsgBox "f(xr) = " & f(xr)
Else
'if the initial guesses are invalid,
'display an error message
MsgBox "No sign change between initial guesses"
End If
End Sub

Function FalsePosMin(xl, xu, es, imax, xr, iter, ea)


Dim xrold As Double, test As Double
Dim fl As Double, fu As Double, fr As Double
iter = 0
fl = f(xl)
fu = f(xu)
Do
xrold = xr
'determine new root estimate
xr = xu - fu * (xl - xu) / (fl - fu)
fr = f(xr)
iter = iter + 1
'determine approximate error
If xr <> 0 Then
ea = Abs((xr - xrold) / xr) * 100#
End If
'determine new bracket
test = fl * fr
If (test < 0) Then
xu = xr
fu = fr
ElseIf (test > 0) Then
xl = xr
fl = fr

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.
25

Else
ea = 0#
End If
'terminate computation if stopping criterion is met
'or maximum iterations are exceeded
If ea < es Or iter >= imax Then Exit Do
Loop
FalsePosMin = xr
End Function

Function f(x)
f = x ^ 10 - 1
End Function

For Example 5.6, the Excel worksheet used for input looks like:

The program yields a root of 0.9996887 after 39 iterations. The approximate error at this point is
9.5×10−3 %. These results are all displayed as message boxes. For example, the solution check is
displayed as

The number of function evaluations for this version is n + 2. This is much smaller than the number of
function evaluations in the standard false position method (5n).

5.27 Here is a VBA Sub procedure to implement the modified false position method. It is set up to evaluate
Example 5.5.

Option Explicit

Sub TestModFP()
Dim imax As Integer, iter As Integer
Dim x As Double, xl As Double, xu As Double
Dim es As Double, ea As Double, xr As Double
Dim root As Double
'input information from the user
Sheets("Sheet1").Select
Range("b4").Select
xl = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
xu = ActiveCell.Value
ActiveCell.Offset(1, 0).Select

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.
26

es = ActiveCell.Value
ActiveCell.Offset(1, 0).Select
imax = ActiveCell.Value
Range("b4").Select
If f(xl) * f(xu) < 0 Then
'if the initial guesses are valid, implement bisection
'and display results
root = ModFalsePos(xl, xu, es, imax, xr, iter, ea)
MsgBox "The root is: " & root
MsgBox "Iterations: " & iter
MsgBox "Estimated error: " & ea
MsgBox "f(xr) = " & f(xr)
Else
'if the initial guesses are invalid,
'display an error message
MsgBox "No sign change between initial guesses"
End If
End Sub

Function ModFalsePos(xl, xu, es, imax, xr, iter, ea)


Dim il As Integer, iu As Integer
Dim xrold As Double, fl As Double
Dim fu As Double, fr As Double, test As Double
iter = 0
fl = f(xl)
fu = f(xu)
Do
xrold = xr
xr = xu - fu * (xl - xu) / (fl - fu)
fr = f(xr)
iter = iter + 1
If xr <> 0 Then
ea = Abs((xr - xrold) / xr) * 100
End If
test = fl * fr
If test < 0 Then
xu = xr
fu = f(xu)
iu = 0
il = il + 1
If il >= 2 Then fl = fl / 2
ElseIf test > 0 Then
xl = xr
fl = f(xl)
il = 0
iu = iu + 1
If iu >= 2 Then fu = fu / 2
Else
ea = 0#
End If
If ea < es Or iter >= imax Then Exit Do
Loop
ModFalsePos = xr
End Function

Function f(x)
f = x ^ 10 - 1
End Function

For Example 5.6, the Excel worksheet used for input looks like:

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.
27

The program yields a root of 1.0000057 after 12 iterations. The approximate error at this point is
1.16×10−3 %. These results are all displayed as message boxes. For example, the solution check is
displayed as

Note that the standard false position method requires 39 iterations to attain comparable accuracy.

5.28 Here is a MATLAB function to implement the algorithm:

function [root,Ea,ea,n] = bisect_iter(func,xl,xu,Ead,varargin)


% bisection roots zero
% [root,Ea,ea,n] = bisect_iter(func,xl,xu,Ead,varargin)
% uses bisection method to find the root of a function
% with a fixed number of iterations to attain
% a prespecified tolerance
% input:
% func = name of function
% xl, xu = lower and upper guesses
% Ead = (optional) desired tolerance (default = 0.000001)
% p1,p2,... = additional parameters used by func
% output:
% root = real root
% Ea = absolute error
% ea = % relative error
% n = iterations

if func(xl,varargin{:})*func(xu,varargin{:})>0 %if guesses do not bracket a


sign change
disp('no bracket') %display an error message
return %and terminate
end
% if necessary, assign default values
if nargin<4|isempty(Ead),Ead=0.000001;end %if Ead blank set to 0.000001
xr = xl;
% compute n and round up to next highest integer
n = round(log2((xu - xl)/Ead) + 0.5);
for i = 1:n
xrold = xr;
xr = (xl + xu)/2;
if xr ~= 0, ea = abs((xr - xrold)/xr) * 100; end
Ea = abs(xr - xrold);
test = func(xl,varargin{:})*func(xr,varargin{:});
if test < 0

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

xu = xr;
elseif test > 0
xl = xr;
else
ea = 0;
end
end
root = xr;

The following is a MATLAB session that uses the function to solve Example 5.3 with Ea,d = 0.0001.

>> format long


>> fcd=@(cd,m,t,v) m*9.81/cd*(1-exp(-cd/m*t))-v;
>> [root,Ea,ea,n] =bisect_iter(fcd,12,16,0.0001,68.1,10,40)

root =
14.801086425781250
Ea =
6.103515625000000e-005
ea =
4.123694335281091e-004
n =
16

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.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy