Docsity

Math 105A Summer 2003-04 Final: Interpolation & Integration Solutions, Exams of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
Jim Lambers
Math 105A
Summer Session I 2003-04
Final Exam Solution
1. Use the Newton divided-difference formula to compute the cubic interpolating polynomial
p3(x) for the function
f(x) = sin πx/2,
using interpolation points x0= 0, x1= 1, x2= 2,and x3= 3.What is an upper bound for
the error |p3(0.5) −f(0.5)|?
Solution The divided-difference table for the given data is
i xif[xi]
0 0 0
1
1 1 1 −1
−1 1/3
2 2 0 0
−1
3 3 −1
It follows that
p3(x) = 0 + x−x(x−1) + 1
3x(x−1)(x−2).
The error in this polynomial is
f(x)−p3(x) = π
24sin πξ/2
4! x(x−1)(x−2)(x−3),
since f(4)(x) = (π/2)4sin πx/2. It follows that
|p3(0.5) −f(0.5)|=π
24sin πξ/2
4! (0.5)(0.5−1)(0.5−2)(0.5−3)
=
π4
16
sin π/2
24
15
16
≤
π4
384
15
16
≤0.23781516365723,
since the maximum of sin πξ/2 on [0,3] occurs at ξ= 1, and the maximum value is equal to
1.
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Math 105A Summer 2003-04 Final: Interpolation & Integration Solutions and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

Jim Lambers Math 105A Summer Session I 2003- Final Exam Solution

  1. Use the Newton divided-difference formula to compute the cubic interpolating polynomial p 3 (x) for the function f (x) = sin πx/ 2 , using interpolation points x 0 = 0, x 1 = 1, x 2 = 2, and x 3 = 3. What is an upper bound for the error |p 3 (0.5) − f (0.5)|? Solution The divided-difference table for the given data is

i xi f [xi] 0 0 0 1 1 1 1 − 1 − 1 1 / 3 2 2 0 0 − 1 3 3 − 1

It follows that p 3 (x) = 0 + x − x(x − 1) +^1 3

x(x − 1)(x − 2). The error in this polynomial is

f (x) − p 3 (x) =

( (^) π 2

) (^4) sin πξ/ 2 4! x(x^ −^ 1)(x^ −^ 2)(x^ −^ 3), since f (4)(x) = (π/2)^4 sin πx/2. It follows that

|p 3 (0.5) − f (0.5)| =

( (^) π 2

) (^4) sin πξ/ 2 4! (0.5)(0.^5 −^ 1)(0.^5 −^ 2)(0.^5 −^ 3)

∣∣^ π

4 16

sin π/ 2 24

∣∣^ π

4 384

since the maximum of sin πξ/2 on [0, 3] occurs at ξ = 1, and the maximum value is equal to

  1. Find the Hermite interpolating polynomial for the following data.

i xi f (xi) f ′(xi) 0 0 0 1 1 1 1 0 2 3 − 1 0

Solution We define z 0 = x 0 , z 1 = x 0 , z 2 = x 1 , z 3 = x 1 , z 4 = x 2 , z 5 = x 2. The divided-difference table for the given data is

i zi f [zi] 0 0 0 1 1 0 0 0 1 − 1 2 1 1 − 1 7 / 18 0 1 / 6 − 5 / 54 3 1 1 − 1 / 2 1 / 9 − 1 1 / 2 4 3 − 1 1 / 2 0 5 3 − 1

It follows that the Hermite interpolating polynomial is

H 5 (x) = x − x^2 (x − 1) +^7 18

x^2 (x − 1)^2 − 5 54

x^2 (x − 1)^2 (x − 3).

  1. Find the cubic spline interpolant s(x) for the data

i xi f (xi) 0 − 1 − 1 1 0 0 2 1 2

that satisfies free, or natural, boundary conditions. Solution The spline s(x) is a piecewise polynomial consisting of the two pieces s 0 (x) = a 0 + b 0 (x − 1) + c 0 (x − 1)^2 + d 0 (x − 1)^3 , s 1 (x) = a 1 + b 1 (x − 3) + c 1 (x − 3)^2 + d 1 (x − 3)^3.

s 1 (x) = 0 +^3 2

(x − 0) +^3 4

(x − 0)^2 − 1 4

(x − 0)^3

= 3 2

x +^3 4

x^2 − 1 4

x^3.

  1. Use Lagrange interpolation to derive a formula for approximating f ′(x 0 ) that uses the values of f (x) at x 0 − h and x 0 + 2h. This formula is accurate to order O(hk), for some k. What is the value of k? Justify your answer. Solution Given a function f (x), we can approximate f ′(x 0 ) by computing p′ 1 (x 0 ), where p 1 (x) is the polynomial that interpolates f (x) at the points x 0 − h and x 0 + 2h. The Lagrange polynomials for these points are given by

L 1 , 0 (x) = x^ −^ (x^0 + 2h) x 0 − h − (x 0 + 2h) =

x − (x 0 + 2h) − 3 h , L 1 , 1 (x) =

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

=

x − (x 0 − h) 3 h. Differentiating, we obtain

L′ 1 , 0 (x) = −^1 3 h

L′ 1 , 1 (x) = (^31) h ,

which yields L′ 1 , 0 (x 0 ) = −^1 3 h

, L′ 1 , 1 (x 0 ) = 1 3 h

We conclude that if p 1 (x) is the polynomial that interpolates f (x) at the points x 0 − h and x 0 + 2h, then because

p 1 (x) = f (x 0 − h)L 1 , 0 (x) + f (x 0 + 2h)L 1 , 1 (x),

we have

f ′(x 0 ) ≈ p′ 1 (x 0 ) = f (x 0 − h) −^1 3 h

  • f (x 0 + 2h)^1 3 h = f^ (x^0 + 2h)^ −^ f^ (x^0 −^ h) 3 h

From Taylor’s Theorem,

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

′′(x 0 ) 2

h^2 − f^

′′′(ξ 1 ) 6

h^3 ,

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

f ′′(x 0 ) 2 4 h

(^2) + f^ ′′′(ξ^2 ) 6 8 h

where ξ 1 ∈ [x 0 − h, x 0 ] and ξ 2 ∈ [x 0 , x 0 + 2h]. Substituting these Taylor expansions into the differentiation rule yields f (x 0 + 2h) − f (x 0 − h) 3 h =^ −^

3 h

[

f (x 0 ) − f ′(x 0 )h + f^

′′(x 0 ) 2 h

(^2) − f^ ′′′(ξ^1 ) 6 h

3

]

3 h

[

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

′′(x 0 ) 2

4 h^2 + f^

′′′(ξ 2 ) 6

8 h^3

]

= f ′(x 0 ) − 1 3 h

[

f ′′(x 0 ) 2

h^2 − f^

′′′(ξ 1 ) 6

h^3

]

3 h

[

f ′′(x 0 ) 2

4 h^2 + f^

′′′(ξ 2 ) 6

8 h^3

]

= f ′(x 0 ) + O(h),

since the terms of O(h) do not cancel.

  1. Use Romberg integration to compute an approximation to ∫ (^1)

− 1

sin(x^2 ) dx

that is sixth-order accurate. Solution We begin by using the Trapezoidal Rule, or, equivalently, the Composite Trape- zoidal Rule ∫ (^) b

a

f (x) dx ≈

h 2

f (a) +

n∑− 1

j=

f (xj ) + f (b)

 (^) , h = b^ −^ a n ,^ xj^ =^ a^ +^ jh,

with n = 1 subintervals. Since h = (b − a)/n = (1 − (−1))/1 = 2, we have

R 1 , 1 =^2 2

[f (−1) + f (1)] = 1. 68294196961579.

Next, we apply the Composite Trapezoidal Rule with n = 2 and h = (1 − (−1))/2 = 1, which yields R 2 , 1 =^1 2

[f (−1) + 2f (0) + f (1)] = 0. 84147098480790.

What is the degree of this quadrature rule?

Solution The particular Gaussian quadrature rule that we will use consists of 3 nodes x 1 , x 2 and x 3 , and 3 weights w 1 , w 2 and w 3. To determine the proper nodes and weights, we use the fact that the nodes and weights of a 3-point Gaussian rule for integrating over the interval [− 1 , 1] are given by

i Nodes r 3 ,i Weights c 3 ,i 1 0. 7745966692 0. 5555555556 2 0. 0000000000 0. 8888888889 3 − 0. 7745966692 0. 5555555556

To obtain the corresponding nodes and weights for integrating over [− 1 , 1], we can use the fact that in general, ∫ (^) b

a

f (x) dx =

− 1

f

b − a 2 t^ +^

a + b 2

b − a 2 dt,

as can be shown using the change of variable x = [(b − a)/2]t + (a + b)/2 that maps [a, b] into [− 1 , 1]. We then have ∫ (^) b

a

f (x) dx =

− 1

f

b − a 2

t + a^ +^ b 2

b − a 2

dt

∑^5

i=

f

b − a 2 r^3 ,i^ +^

a + b 2

b − a 2 c^3 ,i

∑^5

i=

f (xi)wi,

where xi =

b − a 2 r^3 ,i^ +^

a + b 2 ,^ wi^ =^

b − a 2 c^3 ,i,^ i^ = 1,... ,^5. In this example, a = 0 and b = 1, so the nodes and weights for a 3-point Gaussian quadrature rule for integrating over [0, 1] are given by

xi =

2 r^3 ,i^ +

2 ,^ wi^ =

2 c^3 ,i,^ i^ = 1,... ,^3 ,

which yields

i Nodes xi Weights wi 1 0.8872983346 0. 2 0.5000000000 0. 3 0.1127016654 0.

It follows that ∫ (^1)

0

e−x^2 dx ≈

∑^3

i=

wie−x^2 i

≈ 0. 2777777778 e−^0.^8872983346

2

    1. 4444444444 e−^0.^5

2

  1. 2777777778 e−^0.^11270166542 ≈ 0. 74681458419126.

Since the Gaussian quadrature rule has 3 nodes, its degree is 2(3) − 1 = 5.

  1. Use the Composite Simpson’s Rule with m = n = 2 to evaluate the double integral ∫ (^2)

0

∫ (^) x+

0

x^2 + y^2 dy dx.

Solution The Composite Simpson’s Rule with n = 2 subintervals is ∫ (^) b

a

f (x) dx ≈ h 3

[

f (a) + 4f

a + b 2

  • f (b)

]

, h = b^ −^ a n

If a = 0 and b = 2, then h = (2 − 0)/2 = 1 and this simplifies to ∫ (^2)

0

f (x) dx ≈ 1 3

[f (0) + 4f (1) + f (2)].

If we use this rule to evaluate the integrand

f (x) =

∫ (^) x+

0

x^2 + y^2 dy,

at any given x, and also to integrate f (x) over [0, x + 1], for x = 0, 1 , 2, we obtain ∫ (^2)

0

∫ (^) x+

0

x^2 + y^2 dy dx =

0

f (x) dx

≈

3 [f^ (0) + 4f^ (1) +^ f^ (2)] ≈

[∫ 1

0

y^2 dy + 4

0

1 + y^2 dy +

0

4 + y^2 dy

]

[

+ 1^2

]

[

(1 + 0^2 ) + 4(1 + 1^2 ) + (1 + 2^2 )

]