Beruflich Dokumente
Kultur Dokumente
MA/CS/EGR 537
Numerical Analysis
Problem Set 2
Complete problems amounting to at least 80 points. The problems are from the latter half of
chapter 1 and the rst third of chapter 2.
√
1. (15pts) (1.11E) Let f (x) = 1 + x2 − 1
(a) Explain the diculty 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?
2. (20pts) (1.13E) Let f (x) = (1 − cos x)/x, x, x 6= 0.
(a) Show that direct evaluation of f is inaccurate if |x| is small; assume fl(f (x)) = fl(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 rst-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.)
3. (10pts) (E1.27)Determine the condition number for the following functions:
(a) f (x) = ln x, x > 0;
(b) f (x) = cos x, |x| < 12 π ;
(c) f (x) = sin−1 x, |x| < 1;
(d) f (x) = sin−1 √ x
1+x2
.
For each indicate for what values of x the function is ill-conditioned.
4. (5pts) (E1.28) Compute the condition number of the following functions, and discuss any
possible ill-conditioning:
(a) f (x) = x1/n (x > 0, n > 0 an integer);
√
(b) f (x) = x − x2 − 1 (x > 1);
5. (5pts) (1.29E) Show that (condf · g)(x) ≤ (condf )(x) + (condg)(x). What can be said about
(condf /g)(x)?
2
(a) Use integration by parts to obtain a recurrence formula relating yk to yk−1 for k =
1, 2, 3, . . ., and determine the starting value y0 .
(b) Write and run a program that generates y0 , y1 , . . . , y20 ,using the recurrence of (a), and
print the results to 15 decimal digits after the decimal point. Explain in detail (quanti-
tatively, using mathematical analysis) what is happening.
3
(c) Use the recursion of (a) in reverse order, starting (arbitrarily) with yN = 0. Place into ve
consecutive columns of a (21 × 5) matrix Y the values y0(N ) , y1(N ) , . . . , y20
(N )
thus obtained
for N = 22, 24, 26, 28, 30. Determine how much consecutive columns of Y dier from one
another by printing
ei = max |Y (:, i + 1) − Y (:, i)./Y (:, i + 1)|, i = 1, 2, 3, 4.
(The formula above uses Matlab notation for indexing arrays, Matlab's element-wise
notation for division. Also note Matlab arrays are indexed from one, not zero.) Print the
last column Y (:, 5) of Y and explain why this represents accurately the column vector of
the desired quantities y0 , y1 , . . . , y20 .
9. (15pts) (E2.1) Suppose you want to approximate the function
−1 if −1 ≤ t < 0,
f (t) = 0 if t = 0,
1 if 0<t≤1
(a) How must c be chosen if the approximation is to be optimal in the (continuous, equally
weighted) least squares sense?
(b) Sketch the error curves e1 (x) := ex − (1 + x) and e2 := ex − (1 + cx) with c as obtained
in (a) and determine max0≤x≤1 |e1 (x)| and max0≤x≤1 |e2 (x)|.
(c) Solve the analogous problem with three instead of two terms in the modied Taylor
expansion: ex ≈ 1 + c1 + c2 x2 , and provide error curves for e1 (x) = ex − 1 − x − 12 x2 and
e2 (x) = ex − 1 − c1 x − c2 xx ) = xm−1 x t−m e−t dt.
R ∞
4
11. (5pts) (E2.19) Given the recursion relation πk+1 (t) = (t−αk )πk (t)−βk πk−1 (t), k = 0, 1, 2, . . . ,
for the (monic) orthogonal polynomials {πj }, and dening β0 = kπ0 k2 k, show that kπk2 =
β0 β1 · · · βk ,k = 0, 1, 2, . . ..
(c) Using the result from part (b) show that the π̃i for i = 0, 1, . . . , n form a orthogonal basis
for approximating functions on ti for i = 0, 1, n, where ti are the roots of π̃n+1 . (This
requires showing that a particular matrix A is orthogonal, i.e., AT A = AAT is diagonal.
13. (20pts) (M2.4) Write a program for discrete polynomial least squares approximation of a
function f dened on [−1, 1], using the inner product
N
2 X 2i
(u, v) = u(ti )v(ti ), ti = −1 + ,
N +1 N
i=0
(You do not have to prove this.) Dene γk = kπk k2 = (πk , πk ), which is known to be
equal to β0 β1 · · · βk .
(b) Using the recurrence formula with coecients αk , βk given in (a), generate an array
π of dimension (N + 2, N + 1) containing πk (t` ), k = 0, 1, . . . , N + 1; ` = 0, 1, . . . , N .
(Here k is the row index and ` the column index.) Dene µk = max0≤`≤N |πk (t` )|, k =
1, 2, . . . , N + 1. Print βk , γk , and µk+1 for k = 0, 1, 2, . . . , N . where N = 10. Comment
on the results.
5
(c) With p̂n (t) = nk=0 ĉk πk (t), n = 0, 1, . . . , N , denoting the least squares approximation of
P
degree ≤ n to the function f on [−1, 1], dene
ken k2 = kp̂n − f k = (p̂n − f, p̂n − f )1/2 ,
ken k∞ = max |p̂n (ti ) − f (ti )|.
0≤i≤N
Using the array π generated in part (b), compute ĉn , ken k2 , ken k∞ , n = 0, 1, . . . , N , for
the following four functions:
√
f (t) = e−t , f (t) = ln(2 + t), f (t) = 1 + t, f (t) = |t|.
Be sure you compute ken k2 as accurately as possible (See discussion on page 66 of book
regarding equation (2.26)). For N = 10 and for each f , print ĉn , ken k2 , and ken k∞ for
n = 0, 1, 2, . . . , N . Comment on your results. In particular from the information provided
in the output discuss to what extent the compute coecients ĉk may be corrupted by
rounding errors.