Docsity

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

Toggle sidebar
bg1
MATH 128A, SUMMER 2009: HOMEWORK 4 SOLUTIONS
3.4.11. S(x), S0(x), and S00(x) must be continuous at x= 1; so 2 = S1(1) = S0(1) = 2, b=S0
1(1) =
S0
0(1) = −1, and 2c=S00
1(1) = S00
0(1) = −6. The natural boundary condition requires S00(x) to be
zero at x= 0 and x= 2, so 0 = S00
0(0) = 0 and 0 = S00
1(2) = 2c+ 6d. This gives us coefficients
(b, c, d)=(−1,−3,1).
4.1.6a+8a. At the endpoints, we use the one-sided three-point formulas (equation (4.4) in the section and its
mirror-image). At the other points, we use the centered three-point formula (4.5), which is typically
more accurate.
All error bound formulas involve f(3)(ξ) = 8(e2ξ−sin(2ξ)), where ξis an x-value between the
three which are sampled. f(3) is a positive decreasing function on [−0.3,0], so 8(e2ξmin −sin(2ξmin))
is the best possible upper-bound for |f(3)(ξ)|. A less careful bound is 8(e2(0) + 1) = 16.
x f(x) Approx. f0(x) Exact f0(x) Err. Bound (good) Bound (easy)
−0.3−0.27652 −0.06030 −0.03167 0.02864 0.02969 0.05333
−0.2−0.25074 0.57590 0.56180 0.01410 0.01485 0.02667
−0.1−0.16134 1.25370 1.24012 0.01358 0.01413 0.02667
0 0 1.97310 2.00000 0.02690 0.02826 0.05333
4.1.28. The fourth-order Taylor polynomials are
f(x0−2h) = f(x0)−2hf0(x0) +4h2
2! f00(x0)−8h3
3! f000(x0) + 16h4
4! f(4)(x0) +O(h5)
f(x0−h) = f(x0)−hf0(x0) +h2
2! f00(x0)−h3
3! f000(x0) + h4
4! f(4)(x0) +O(h5)
f(x0+h) = f(x0) +hf0(x0) +h2
2! f00(x0) + h3
3! f000(x0) + h4
4! f(4)(x0) +O(h5)
f(x0+ 2h) = f(x0) +2hf0(x0) +4h2
2! f00(x0) + 8h3
3! f000(x0) + 16h4
4! f(4)(x0) +O(h5)
If we ignore all O(h4) (and higher) terms, this is a system of linear equations which can be “solved”
for the underlined unknowns. One way to isolate f000(x0) is to first cancel the even-order terms:
f(x0+h)−f(x0−h) = 2hf0(x0) +2h3
3! f000(x0) +O(h5)
f(x0+ 2h)−f(x0−2h) = 4hf0(x0) +16h3
3! f000(x0) +O(h5)
We can then eliminate f0(x0):
f(x0+ 2h)−2f(x0+h)+2f(x0−h)−f(x0−2h) = 12h3
3! f000(x0) + O(h5) = 2h3f000 (x0) + O(h5).
Dividing the left-hand side by 2h3yields a formula for f000(x0) with error O(h5/2h3) = O(h2).
4.1.29. e(h) has a critical point on (0,∞) when 0 = e0(h) = −h−2+Mh/3. The unique solution to this
equation is h=3
p3/M ∈(0,∞). (Since e(h)→+∞as h→0+and h→ ∞,e(h) must take its
minimum value at this critical point.)
4.2.10. (As a matter of taste, I’m changing the signs of the constants Ki.)
Date: Due Thursday 7/16.
1
pf3
pf4

Partial preview of the text

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

MATH 128A, SUMMER 2009: HOMEWORK 4 SOLUTIONS

3.4.11. S(x), S′(x), and S′′(x) must be continuous at x = 1; so 2 = S 1 (1) = S 0 (1) = 2, b = S 1 ′(1) = S′ 0 (1) = −1, and 2c = S 1 ′′ (1) = S′′ 0 (1) = −6. The natural boundary condition requires S′′(x) to be zero at x = 0 and x = 2, so 0 = S′′ 0 (0) = 0 and 0 = S′′ 1 (2) = 2c + 6d. This gives us coefficients (b, c, d) = (− 1 , − 3 , 1). 4.1.6a+8a. At the endpoints, we use the one-sided three-point formulas (equation (4.4) in the section and its mirror-image). At the other points, we use the centered three-point formula (4.5), which is typically more accurate. All error bound formulas involve f (3)(ξ) = 8(e^2 ξ^ − sin(2ξ)), where ξ is an x-value between the three which are sampled. f (3)^ is a positive decreasing function on [− 0. 3 , 0], so 8(e^2 ξmin^ − sin(2ξmin)) is the best possible upper-bound for |f (3)(ξ)|. A less careful bound is 8(e2(0)^ + 1) = 16. x f (x) Approx. f ′(x) Exact f ′(x) Err. Bound (good) Bound (easy) − 0. 3 − 0. 27652 − 0. 06030 − 0. 03167 0. 02864 0. 02969 0. 05333 − 0. 2 − 0. 25074 0. 57590 0. 56180 0. 01410 0. 01485 0. 02667 − 0. 1 − 0. 16134 1. 25370 1. 24012 0. 01358 0. 01413 0. 02667 0 0 1. 97310 2. 00000 0. 02690 0. 02826 0. 05333 4.1.28. The fourth-order Taylor polynomials are

f (x 0 − 2 h) = f (x 0 ) − 2 hf ′(x 0 ) +

4 h^2 2! f ′′(x 0 ) −

8 h^3 3! f ′′′(x 0 ) +

16 h^4 4! f (4)(x 0 ) +O(h^5 )

f (x 0 − h) = f (x 0 ) −hf ′(x 0 ) +

h^2 2!

f ′′(x 0 ) −

h^3 3!

f ′′′(x 0 ) +

h^4 4!

f (4)(x 0 ) +O(h^5 )

f (x 0 + h) = f (x 0 ) +hf ′(x 0 ) +

h^2 2!

f ′′(x 0 ) +

h^3 3!

f ′′′(x 0 ) +

h^4 4!

f (4)(x 0 ) +O(h^5 )

f (x 0 + 2h) = f (x 0 ) +2hf ′(x 0 ) +

4 h^2 2! f ′′(x 0 ) +

8 h^3 3! f ′′′(x 0 ) +

16 h^4 4! f (4)(x 0 ) +O(h^5 )

If we ignore all O(h^4 ) (and higher) terms, this is a system of linear equations which can be “solved” for the underlined unknowns. One way to isolate f ′′′(x 0 ) is to first cancel the even-order terms:

f (x 0 + h) − f (x 0 − h) = 2 hf ′(x 0 ) +

2 h^3 3!

f ′′′(x 0 ) +O(h^5 )

f (x 0 + 2h) − f (x 0 − 2 h) = 4 hf ′(x 0 ) + 16 h^3 3!

f ′′′(x 0 ) +O(h^5 )

We can then eliminate f ′(x 0 ):

f (x 0 + 2h) − 2 f (x 0 + h) + 2f (x 0 − h) − f (x 0 − 2 h) =

12 h^3 3!

f ′′′(x 0 ) + O(h^5 ) = 2h^3 f ′′′(x 0 ) + O(h^5 ).

Dividing the left-hand side by 2h^3 yields a formula for f ′′′(x 0 ) with error O(h^5 / 2 h^3 ) = O(h^2 ). 4.1.29. e(h) has a critical point on (0, ∞) when 0 = e′(h) = −h−^2 + M h/3. The unique solution to this equation is h = 3

3 /M ∈ (0, ∞). (Since e(h) → +∞ as h → 0 +^ and h → ∞, e(h) must take its minimum value at this critical point.) 4.2.10. (As a matter of taste, I’m changing the signs of the constants Ki.)

Date: Due Thursday 7/16.

We could write out the three power series and try to find a linear combination in which the h^2 and h^4 terms cancel. An easier method is to extrapolate M from N (h) and N (h/3): N (h) = M +K 1 h^2 +K 2 h^4 +K 3 h^6 +...

N (h/3) = M +

K 1

h^2 +

K 2

h^4 +

K 3

h^6 +...

9 N (h/3) − N (h) = 8M − 0 −

8 K 2

h^4 +

80 K 3

h^6 +...

So set N 2 (h) = 9 N (h/3) − N (h) 8

Its expansion is M − K 92 h^4 + 1081 K 3 h^6 +.... Notice that N 2 (h/3)

involves N (h/9). So we can get the desired approximation through one more step of extrapolation.

N 2 (h) = M +

K 2

h^4 +

10 K 3

h^6 +...

N 2 (h/3) = M +

K 2

h^4 +

10 K 3

h^6 +...

81 N 2 (h/3) − N 2 (h) = 80M +0 −

80 K 3

h^6 +...

Then take N 3 (h) =

81 N 2 (h/3) − N 2 (h) 80

and we’re done.

n

− 1 x

n (^) dx (−√ 3 /3)n (^) + (+√ 3 /3)n 0 2 2 1 0 0 2 2 / 3 2 / 3 3 0 0 4 2 / 5 2 / 9 We see from the table that the indicated quadrature rule exactly integrates x^0 ,... , x^3 but not x^4. Thus, its degree of precision is 3. 4.3.24. Note: The problem is more reasonable if you are asked to plug in f (x) = xn^ for n = 0, 1, and 2. Possible solution to the original problem: Plug f (x) = x, f (x) = x^2 , and f (x) = x^3 into the equation

∫ (^) x 2 x 0 f^ (x)^ dx^ =^ a^0 f^ (x^0 ) +^ a^1 f^ (x^1 ) + a 2 f (x 2 ) + kf (4)(ξ). This produces 1 2

(x^22 − x^20 ) = a 0 x 0 + a 1 x 1 + a 2 x 2 1 3

(x^32 − x^30 ) = a 0 x^20 + a 1 x^21 + a 2 x^22 1 4

(x^42 − x^40 ) = a 0 x^30 + a 1 x^31 + a 2 x^32

Since the nodes are separated by a distance of h, we may plug in x 0 = x 1 − h and x 2 = x 1 + h. After expanding, we get

a 0 (x 1 − h) + a 1 x 1 + a 2 (x 1 + h) =

(4x 1 h) = 2x 1 h

a 0 (x 1 − h)^2 + a 1 x^21 + a 2 (x 1 + h)^2 =

(6x^21 h + 2h^3 ) = 2x^21 h + 2h^3 / 3

a 0 (x 1 − h)^3 + a 1 x^31 + a 2 (x 1 + h)^3 =

(8x^31 h + 8x 1 h^3 ) = 2x^31 h + 2x 1 h^3

4.5.8. Since R 2 , 1 is just the composite trapezoidal approximation to

∫ (^) b a f^ (x)^ dx^ with^ n^ = 2, we can just compute R 2 , 1 is b− 4 a [f (a)+f (b)+2f ( a+ 2 b)]. Or we can notice that R 2 , 2 is calculated from the formula R 2 , 2 = R 2 , 1 + R^2 ,^1 − 3 R^1 ,^1 ; since R 2 , 2 and R 1 , 1 are given, we can solve for R 2 , 1. Both methods give us R 2 , 1 ≈ 0 .2361.