Homework 5 Solutions | Numerical Analysis | MATH 128A, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Material Type: Assignment; Class: Numerical Analysis; Subject: Mathematics; University: University of California - Berkeley; Term: Summer 2009;

Typology: Assignments

Pre 2010

Uploaded on 10/01/2009

koofers-user-uvh
koofers-user-uvh 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MATH 128A, SUMMER 2009: HOMEWORK 5 SOLUTIONS
(1) Given a quadrature rule of the form Rb
af(x)dx Pn
i=0 cif(xi), let f(x) be [(xx0). . . (xxn)]2,
a polynomial of degree 2(n+ 1).
Since f(x) is a continuous function, positive except at its n+1 roots, the exact value of Rb
af(x)dx
must be positive.
Since f(x) is zero when x=xi, the estimate for Rb
af(x)dx given by the quadrature rule is zero.
Since the quadrature can’t integrate f(x) (a polynomial of degree 2(n+ 1)) exactly, its degree of
precision must be less than 2(n+ 1).
(2) Use the inner product hf, g i=R
0exf(x)g(x)dx for functions on [0,).
Let f(x) be a polynomial of degree 2n1 (or less). use polynomial division to express f(x) in the
form q(x)Ln(x)+r(x), where q(x) (the quotient) is a polynomial of degree at most (2n1)n=n1,
and r(x) (the remainder) is a polynomial of degree less than n.
The quadrature rule estimates R
0exq(x)Ln(x)dx exactly due to the choice of nodes: Since
deg q(x)n1, q(x) is orthogonal to Ln(x): the value of R
0exq(x)Ln(x)dx is zero. Since
q(x)Ln(x) = 0 when x=xi,Pn
i=1 cn,if(xi) is also zero.
The quadrature rule estimates R
0r(x)dx exactly due to the choice of coefficients: Let Pn,i (x) =
Qn
j=1
j6=i
xxj
xixjbe the Legendre interpolating polynomial (with Pn,i (xi) = 1 and Pn,i (xj) = 0 for
j6=i). Since deg r(x)n1, r(x) equals the interpolating polynomial Pn
i=1 r(xi)Pn,i(x). So
R
0exr(x)dx =Pn
i=1 r(xi)R
0exPn,i(x)dx =Pn
i=1 r(xi)cn,i.
Therefore, the quadrature rule is exact if f(x) is a polynomial of degree at most 2n1. So the
degree of precision of this quadrature rule is at least 2n1. In fact it’s exactly 2n1 by essentially
the same argument from the previous problem.
The roots of L2(x) = x24x+ 2 are x1= 2 2 and x2= 2 + 2. Thus, the polynomials Pn,i
above are
P2,1=x(2 + 2)
22=2
4x+1 + 2
2, P2,2=x(2 2)
+22=+2
4x+12
2
We can compute cn,i =R
0Pn,i(x)exdx using R
0x0exdx = 1 and R
0x1exdx = 1.1c2,1=
2+2
4,c2,2=22
4, and the quadrature rule is R
0exf(x)dx 2+2
4f(2 2) + 22
4f(2 + 2)
0.854f(0.586) + 0.146f(3.414).
(Consider solutions correct if degree of precision >2n1 is not ruled out, or if c2,i are only
estimated.)
(3) Using a suitable substitution, transform each of the following into an integral on the indicated
interval.
(a) Example: using x= (1 + t)/2, dx =dt/2: Z1
1
sin(π(1 + t)2/4)/2dt.
(b) Example: using x= 1/t,dx =dt/t2:Z0
1sin(1/t)dt =Z0
1
sin(1/t)dt.
(c) Using x=1+u
1u,dx = 2(1 u)2du:Z1
1
2(1 + u)4(1 u)6e(u+1)/(u1) du.
Date: Due Friday 7/24.
1The first integral is easy. For n > 0, integration by parts gives R
0xnexdx = [xn
· ex]
0
R
0
exnxn1dx =
nR
0xn1exdx. So R
0xnexdx =n!.
1
pf2

Partial preview of the text

Download Homework 5 Solutions | Numerical Analysis | MATH 128A and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MATH 128A, SUMMER 2009: HOMEWORK 5 SOLUTIONS

(1) Given a quadrature rule of the form

∫ (^) b a f^ (x)^ dx^ ≈^

∑n i=0 cif^ (xi), let^ f^ (x) be [(x^ −^ x^0 )^...^ (x^ −^ xn)]

a polynomial of degree 2(n + 1). Since f (x) is a continuous function, positive except at its n + 1 roots, the exact value of

∫ (^) b a f^ (x)^ dx must be positive. Since f (x) is zero when x = xi, the estimate for

∫ (^) b a f^ (x)^ dx^ given by the quadrature rule is zero. Since the quadrature can’t integrate f (x) (a polynomial of degree 2(n + 1)) exactly, its degree of precision must be less than 2(n + 1). (2) Use the inner product 〈f, g〉 =

0 e

−xf (x)g(x) dx for functions on [0, ∞). Let f (x) be a polynomial of degree 2n − 1 (or less). use polynomial division to express f (x) in the form q(x)Ln(x)+r(x), where q(x) (the quotient) is a polynomial of degree at most (2n−1)−n = n−1, and r(x) (the remainder) is a polynomial of degree less than n. The quadrature rule estimates

0 e

−xq(x)Ln(x) dx exactly due to the choice of nodes: Since deg q(x) ≤ n − 1, q(x) is orthogonal to Ln(x): the value of

0 e

−xq(x)Ln(x) dx is zero. Since q(x)Ln(x) = 0 when x = xi,

∑n i=1 cn,if^ (xi) is also zero. The quadrature rule estimates

∏^0 r(x)^ dx^ exactly due to the choice of coefficients: Let^ Pn,i(x) = n j= j 6 =i

x−xj xi−xj be the Legendre interpolating polynomial (with^ Pn,i(xi) = 1 and^ Pn,i(xj^ ) = 0 for j 6 = i). Since deg r(x) ≤ n − 1, r(x) equals the interpolating polynomial

∑n ∫ (^) ∞ i=1^ r(xi)Pn,i(x).^ So 0 e

−xr(x) dx = ∑n i=1 r(xi)^

0 e

−xPn,i(x) dx = ∑n i=1 r(xi)cn,i. Therefore, the quadrature rule is exact if f (x) is a polynomial of degree at most 2n − 1. So the degree of precision of this quadrature rule is at least 2n − 1. In fact it’s exactly 2n − 1 by essentially the same argument from the previous problem. The roots of L 2 (x) = x^2 − 4 x + 2 are x 1 = 2 −

2 and x 2 = 2 +

  1. Thus, the polynomials Pn,i above are

P 2 , 1 =

x − (2 +

x +

, P 2 , 2 =

x − (2 −

x +

We can compute cn,i =

0 Pn,i(x)e

−x (^) dx using ∫^ ∞ 0 x

(^0) e−x (^) dx = 1 and ∫^ ∞ 0 x

(^1) e−x (^) dx = 1. (^1) c 2 , 1 = 2+ √ 2 4 ,^ c^2 ,^2 =^

2 − √ 2 4 , and the quadrature rule is^

0 e

−xf (x) dx ≈ 2+ √ 2 4 f^ (2^ −

√ 2 4 f^ (2 +^

  1. 854 f (0.586) + 0. 146 f (3.414). (Consider solutions correct if degree of precision > 2 n − 1 is not ruled out, or if c 2 ,i are only estimated.) (3) Using a suitable substitution, transform each of the following into an integral on the indicated interval. (a) Example: using x = (1 + t)/2, dx = dt/2:

− 1

sin(π(1 + t)^2 /4)/ 2 dt.

(b) Example: using x = 1/t, dx = −dt/t^2 :

1

− sin(1/t) dt =

1

sin(1/t) dt.

(c) Using x = 1+ 1 −uu , dx = 2(1 − u)−^2 du:

− 1

2(1 + u)^4 (1 − u)−^6 e(u+1)/(u−1)^ du.

Date: Due Friday 7/24. (^1) The first integral is easy. For n > 0, integration by parts gives R^ ∞ 0 x ne−x (^) dx = [xn (^) · −e−x]∞ 0 −^

R (^) ∞ 0 −e −xnxn− (^1) dx =

n R (^) ∞ 0 x n− (^1) e−x (^) dx. So R^ ∞ 0 x ne−x (^) dx = n!. 1

(4) Laguerre quadrature gives 20 and Gaussian quadrature gives about 52. Laguerre quadrature came much closer to 24 (and impressively close for only two nodes). (This makes sense: Laguerre quadra- ture is estimating the kind of integral it was designed for, whereas Gaussian quadrature is seeing a fairly unfriendly integrand.) (5) (a) The integrand x−^1 is smooth on [1, 4] (good for Romberg), and easily approximated by polyno- mials (good for Newton-Cotes and Gaussian). (b) The adaptive method is free to spend less time on subintervals that affect the outcome less. For instance, the integral on [2, 4] is only half as large as the integral on [1, 2], but the fixed-step-size method must spend twice as much time on it. (c) The composite midpoint and trapezoidal methods can’t exploit the problem’s smoothness to as high a degree as the others. (6) (a) The function |x| is difficult to approximate by polynomials on this domain, due to its corner. As the number of nodes increases, the Newton-Cotes estimates become integrals of very bad polynomial approximations. (b) An adaptive method will notice that the integral is easy on any interval which doesn’t contain the corner (x = 0). So it will always bisect the interval that contains the corner, effectively halving the error each time it adds nodes. (7) (a) Gaussian quadrature performs well when the integrand is a high-degree polynomial, because it was specifically designed to integrate polynomials with a high degree of precision. (b) An adaptive method can repeatedly refine its estimate on the leftmost and rightmost subin- tervals, where most of the error is being made. Newton-Cotes works well since it estimates a high-degree polynomial with a high-degree polynomial; absent round-off error, it would even be exact if it used more than 60 nodes. (c) Although Gaussian quadrature with more than 30 nodes has a sufficient degree of precision to estimate the integral exactly, computer round-off error prevents this from happening in practice. (8) Note that ∂f∂y = −et−y^ exists for all (t, y). (i) No, | − et−y^ | increases without bound as y → −∞.

(ii) Yes, | − et−y^ | ≤ e if t ≤ 1 and y ≥ 0. (iii) (i) can’t, but (ii) can: if y(0) ≈ 1, then y(0) > 0 and y′(t) = f (t, y(t)) > 0 for all t ∈ [0, 1] imply that y(t) > 0 for all t ∈ [0, 1]. Thus, the Lipschitz condition (ii) (and continuity of f (t, y)) is enough to show the problem is well-posed. (9) The absolute value of (^) ∂y∂ (1 + y/t) = 1/t is bounded by L = 1 on [1, 2] (in fact, on each [1, ti]).

The absolute value of y′′(t) = (^) dtd (1 + y/t) = y′/t − y/t^2 = (1/t + y/t^2 ) − y/t^2 = 1/t (alternatively, y′′(t) = d

2 dt^2 (t^ ln^ t^ + 2t) = 1/t) is bounded by^ M^ = 1 on [1,^ 2] (in fact, on each [1, ti]). So at^ t^ =^ ti, a bound on the total error is given by hM 2 L (e(ti−t^0 )/L^ − 1) = h 2 (eih^ − 1). i ti wi yi |yi − wi| error bound 0 1. 00 2. 0000000 2. 0000000 0. 0000000 0. 0000000 1 1. 25 2. 7500000 2. 7789294 0. 0289294 0. 0355032 2 1. 50 3. 5500000 3. 6081977 0. 0581977 0. 0810902 3 1. 75 4. 3916667 4. 4793276 0. 0876610 0. 1396250 4 2. 00 5. 2690476 5. 3862944 0. 1172467 0. 2147852

2