Numerical Analysis 2nd Edition
By
Walter Gautschi
( All Chapters Included - 100% Verified Solutions )
1
,EXERCISES AND MACHINE ASSIGNMENTS TO CHAPTER 1
EXERCISES
1. Represent all elements of R+ (3, 2) = {x ∈ R(3, 2) : x > 0, x normalized} as
dots on the real axis. For clarity, draw two axes, one from 0 to 8, the other
from 0 to 21 .
2. (a) What is the distance d(x) of a positive normalized floating-point number
x ∈ R(t, s) to its next larger floating-point number:
d(x) = min (y − x) ?
y∈R(t,s)
y>x
(b) Determine the relative distance r(x) = d(x)/x, with x as in (a), and
give upper and lower bounds for it.
3. The identity fl(1 + x) = 1, x ≥ 0, is true for x = 0 and for x sufficiently small.
What is the largest machine number x for which the identity still holds?
4. Consider a miniature binary computer whose floating-point words consist of
4 binary digits for the mantissa and 3 binary digits for the exponent (plus
sign bits). Let
x = (.1011)2 × 20 , y = (.1100)2 × 20 .
Mark in the following table whether the machine operation indicated (with
the result z assumed normalized) is exact, rounded (i.e., subject to a nonzero
rounding error), overflows, or underflows.
operation exact rounded overflow underflow
z = fl(x − y)
z = fl((y − x)10 )
z = fl(x + y)
z = fl(y + (x/4))
z = fl(x + (y/4))
5. The Matlab “machine precision” eps is twice the unit roundoff (2 × 2−t ,
t = 53; cf. Sect. 1.1.3). It can be computed by the following Matlab program
(attributed to Cleve Moler):
%EI_5 Matlab machine precision
%
a=4/3;
b=a-1;
c=b+b+b;
eps0=abs(c-1)
2
,4 Exercises to Chapter 1
Run the program and prove its validity.
6. Prove (1.12).
7. A set S of real numbers is said to possess a metric if there is defined a
distance function d(x, y) for any two elements x, y ∈ S that has the following
properties:
(i) d(x, y) ≥ 0 and d(x, y) = 0 if and only if x = y (positive definiteness);
(ii) d(x, y) = d(y, x) (symmetry);
(iii) d(x, y) ≤ d(x, z) + d(z, y) (triangle inequality).
Discuss which of the following error measures is, or is not, a distance function
on what set S of real numbers:
(a) absolute error: ae(x, y) = |x − y|;
x−y
(b) relative error: re(x, y) = x ;
(c) relative precision (F.W.J. Olver, 1978): rp(x, y) = | ln |x| − ln |y| |.
If y = x(1 + ε), show that rp(x, y) = O(ε) as ε → 0.
8. Assume that x∗1 , x∗2 are approximations to x1 , x2 with relative errors E1 and
E2 , respectively, and that |Ei | ≤ E, i = 1, 2. Assume further that x1 6= x2 .
(a) How small must E (in dependence of x1 and x2 ) be in order to ensure
that x∗1 6= x∗2 ?
1 1
(b) Taking ∗ ∗ to approximate , obtain a bound on the relative
x1 − x2 x1 − x2
error committed, assuming (1) exact arithmetic; (2) machine arithmetic
with machine precision eps. (In both cases, neglect higher-order terms
in E1 , E2 , eps.)
9. Consider the quadratic equation x2 + px + q = 0 with roots x1 , x2 . As
seen in the second Example of Sect. 1.2.2, the absolutely larger root must
be computed first, whereupon the other can be accurately obtained from
x1 x2 = q. Suppose one incorporates this idea in a program such as
x1=abs(p/2)+sqrt(p*p/4-q);
if p>0, x1=-x1; end
x2=q/x1;
Find two serious flaws with this program as a “general-purpose quadratic
equation solver.” Take into consideration that the program will be executed
in floating-point machine arithmetic. Be specific and support your arguments
by examples, if necessary.
3
, Exercises to Chapter 1 5
10. Suppose, for |x| small, one has an accurate value of y = ex − 1 (obtained,
e.g., by Taylor expansion). Use this value to compute accurately sinh x =
1 x −x
2 (e − e ) for small |x|.
√
11. Let f (x) = 1 + x2 − 1.
(a) Explain the difficulty of computing f (x) for a small value of |x| and
show how it can be circumvented.
(b) Compute (cond f )(x) and discuss the conditioning of f (x) for small |x|.
(c) How can the answers to (a) and (b) be reconciled?
12. The nth power of some positive (machine) number x can be computed
(i) either by repeated multiplication by x, or
(ii) as xn = en ln x .
In each case, derive bounds for the relative error due to machine arithmetic,
neglecting higher powers of the machine precision against the first power.
(Assume that exponentiation and taking logarithms both involve a relative
error ε with |ε| ≤ eps.) Based on these bounds, state a criterion (involving x
and n) for (i) to be more accurate than (ii).
13. Let f (x) = (1 − cos x)/x, x 6= 0.
(a) Show that direct evaluation of f is inaccurate if |x| is small; assume
fl(f (x)) = fl((1 − fl(cos x))/x), where fl(cos x) = (1 + εc ) cos x, and
estimate the relative error εf of fl(f (x)) as x → 0.
(b) A mathematically equivalent form of f is f (x) = sin2 x/(x(1 + cos x)).
Carry out a similar analysis as in (a), based on fl(f (x)) = fl([fl(sin x)]2 /
fl(x(1 + fl(cos x)))), assuming fl(cos x) = (1 + εc ) cos x, fl(sin x) = (1 +
εs ) sin x and retaining only first-order terms in εs and εc . Discuss the
result.
(c) Determine the condition of f (x). Indicate for what values of x (if any)
f (x) is ill-conditioned. (|x| is no longer small, necessarily.)
1/2 1/2
√ r+x r−x
14. If z = x + iy, then z = +i , where r = (x2 +
2 2
1/2
√ r+x
y 2 )1/2 . Alternatively, z = u + iv, u = , v = y/2u. Discuss the
2
computational merits of these two (mathematically equivalent) expressions.
Illustrate with z = 4.5 + .025i, using 8 significant decimal places. {Hint: you
may assume x > 0 without restriction of generality. Why?}
4