Numerical Methods HW1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

cha01064_ch03.

qxd

3/20/09

11:21 AM

Page 76

APPROXIMATIONS AND ROUND-OFF ERRORS

76

the sum are much larger than the final result of the sum. Furthermore, unlike the previous
case, the individual terms vary in sign. Thus, in effect we are adding and subtracting large
numbers (each with some small error) and placing great significance on the differences
that is, subtractive cancellation. Thus, we can see that the culprit behind this example of
smearing is, in fact, subtractive cancellation. For such cases it is appropriate to seek some
other computational strategy. For example, one might try to compute y = e10 as y = (e1)10.
Other than such a reformulation, the only general recourse is extended precision.
Inner Products. As should be clear from the last sections, some infinite series are particularly prone to round-off error. Fortunately, the calculation of series is not one of the more
common operations in numerical methods. A far more ubiquitous manipulation is the
calculation of inner products, as in
n

xi yi = x1 y1 + x2 y2 + + xn yn
i=1

This operation is very common, particularly in the solution of simultaneous linear algebraic equations. Such summations are prone to round-off error. Consequently, it is often
desirable to compute such summations in extended precision.
Although the foregoing sections should provide rules of thumb to mitigate round-off
error, they do not provide a direct means beyond trial and error to actually determine the
effect of such errors on a computation. In Chap. 4, we will introduce the Taylor series,
which will provide a mathematical approach for estimating these effects.

PROBLEMS
3.1 Convert the following base-2 numbers to base-10: (a) 1011001,
(b) 110.00101 and (c) 0.01011
3.2 Convert the following base-8 numbers to base 10: 71,563 and
3.14.
3.3 Compose your own program based on Fig. 3.11 and use it to
determine your computers machine epsilon.
3.4 In a fashion similar to that in Fig. 3.11, write a short program
to determine the smallest number, xmin , used on the computer you
will be employing along with this book. Note that your computer
will be unable to reliably distinguish between zero and a quantity
that is smaller than this number.
3.5 The infinite series
n

1
f (n) =
4
i
i=1
converges on a value of f (n) = /90 as n approaches infinity.
Write a program in single precision to calculate f (n) for
n = 10,000 by computing the sum from i = 1 to 10,000. Then
repeat the calculation but in reverse orderthat is, from
i = 10,000 to 1 using increments of 1. In each case, compute the
true percent relative error. Explain the results.
4

3.6 Evaluate e5 using two approaches


ex = 1 x +

x2
x3

+
2
3!

and
ex =

1
=
ex

1
x2
x3
1+x +
+
+
2
3!

and compare with the true value of 6.737947 103 . Use 20 terms
to evaluate each series and compute true and approximate relative
errors as terms are added.
3.7 The derivative of f(x) = 1/(1 3x 2 ) is given by
6x
(1 3x 2 )2
Do you expect to have difficulties evaluating this function at
x = 0.577? Try it using 3- and 4-digit arithmetic with chopping.
3.8 (a) Evaluate the polynomial
y = x 3 7x 2 + 8x 0.35

cha01064_ch04.qxd

3/20/09

11:46 AM

Page 105

PROBLEMS

105

4.1 The Maclaurin series expansion for cos x is

4.8 The Stefan-Boltzmann law can be employed to estimate the


rate of radiation of energy H from a surface, as in

PROBLEMS

cos x = 1

x4
x6
x8
x2
+

+

2
4!
6!
8!

Starting with the simplest version, cos x = 1, add terms one at a


time to estimate cos(/3). After each new term is added, compute
the true and approximate percent relative errors. Use your pocket
calculator to determine the true value. Add terms until the absolute
value of the approximate error estimate falls below an error criterion conforming to two significant figures.
4.2 Perform the same computation as in Prob. 4.1, but use the
Maclaurin series expansion for the sin x to estimate sin(/3).
sin x = x

x3
x5
x7
+

+
3!
5!
7!

H = Ae T 4
where H is in watts, A = the surface area (m 2 ), e = the emissivity
that characterizes the emitting properties of the surface (dimensionless), = a universal constant called the Stefan-Boltzmann
constant (= 5.67 108 W m2 K4 ), and T = absolute temperature (K). Determine the error of H for a steel plate with A =
0.15 m2 , e = 0.90, and T = 650 20. Compare your results with
the exact error. Repeat the computation but with T = 650 40.
Interpret your results.
4.9 Repeat Prob. 4.8 but for a copper sphere with
radius = 0.15 0.01 m, e = 0.90 0.05, and T = 550 20.
4.10 Recall that the velocity of the falling parachutist can be computed by [Eq. (1.10)],

4.3 The following infinite series can be used to approximate e x :


x2
x3
xn
+
+ +
e =1+x +
2
3!
n!

v(t) =

(a) Prove that this Maclaurin series expansion is a special case of


the Taylor series expansion [(Eq. (4.7)] with xi = 0 and h = x .
(b) Use the Taylor series to estimate f(x) = ex at xi+1 = 1 for
xi = 0.2. Employ the zero-, first-, second-, and third-order versions and compute the |t | for each case.
4.4 Use zero- through fourth-order Taylor series expansions to predict f(2.5) for f(x) = ln x using a base point at x = 1. Compute
the true percent relative error t for each approximation. Discuss
the meaning of the results.
4.5 Use zero- through third-order Taylor series expansions to
predict f(3) for
f(x) = 25x 3 6x 2 + 7x 88
using a base point at x = 1. Compute the true percent relative error
t for each approximation.
4.6 Use forward and backward difference approximations of O(h)
and a centered difference approximation of O(h 2 ) to estimate the
first derivative of the function examined in Prob. 4.5. Evaluate the
derivative at x = 2 using a step size of h = 0.2. Compare your
results with the true value of the derivative. Interpret your results
on the basis of the remainder term of the Taylor series expansion.
4.7 Use a centered difference approximation of O(h 2 ) to estimate
the second derivative of the function examined in Prob. 4.5. Perform the evaluation at x = 2 using step sizes of h = 0.25 and
0.125. Compare your estimates with the true value of the second
derivative. Interpret your results on the basis of the remainder term
of the Taylor series expansion.


gm
1 e(c/m)t
c

Use a first-order error analysis to estimate the error of v at t = 6, if


g = 9.8 and m = 50 but c = 12.5 1.5.
4.11 Repeat Prob. 4.10 with g = 9.8, t = 6, c = 12.5 1.5, and
m = 50 2.
4.12 Evaluate
 and interpret the condition numbers for
(a) f(x) = |x 1| + 1
for x = 1.00001
for x = 10
(b) f(x) = ex
for x = 300
(c) f(x) = x 2 + 1 x
ex 1
for x = 0.001
(d) f(x) =
x
sin x
for x = 1.0001
(e) f(x) =
1 + cos x
4.13 Employing ideas from Sec. 4.2, derive the relationships from
Table 4.3.
4.14 Prove that Eq. (4.4) is exact for all values of x if f(x) =
ax 2 + bx + c.
4.15 Mannings formula for a rectangular channel can be written as
Q=

1 (B H )5/3
S
n (B + 2H )2/3

where Q = flow (m3/s), n = a roughness coefficient, B = width


(m), H = depth (m), and S = slope. You are applying this formula
to a stream where you know that the width = 20 m and the
depth = 0.3 m. Unfortunately, you know the roughness and the
slope to only a 10% precision. That is, you know that the roughness is about 0.03 with a range from 0.027 to 0.033 and the slope is
0.0003 with a range from 0.00027 to 0.00033. Use a first-order

You might also like