Docsity

Midterm II Solutions for Numerical Analysis for Computing | COT 4501, Exams of Computer Science

Toggle sidebar
bg1
Numerical Analysis for Computing
COT 4501
Spring 2005
Midterm II Solutions
April 21, 2009
1. [35 points] Newton Error Formula: Let f∈C2(I) be given, for some interval I⊂ R,with
f(α) = 0 for some α∈I. For a given xn∈I, define
xn+1 =xn−f(xn)
f′(xn).
Then there exists a point ξnbetween αand xnsuch that
(α−xn+1) = −1
2(α−xn)2f′′(ξn)
f′(xn).
(a) [5 points] If ξn→αand xn→αas n→ ∞, what does the ratio Rn=α−xn+1
(α−xn)2converge to?
The ratio Rn=α−xn+1
(α−xn)2converges to limn→∞ Rn=−1
2limn→∞ f′′(ξn)
f′(xn)=−1
2
f′′(α)
f′(α).
(b) [5 points] Evaluate Rn(in the limiting case as n→ ∞) for f(x) = 2e−βx −1.
For f(x) = 2e−βx −1, f′(x) = −2βe−β x and f′′(x) = 2β2e−βx . Therefore, limn→∞ Rn=
−1
2
f′′(α)
f′(α)=β
2.
(c) [10 points] The Newton Error Formula can be used to approximately “peek ahead” at the
solution f(α) = 0 when we are getting close to convergence. Imagine that you are executing
Newton’s method and are at time step n. You think you are somewhat close to the true answer.
In order to get a better estimate ˆα(n) of the true answer α, you replace ξnby xnin the Newton
Error Formula to get an estimate ˆα(n). Using this approximation in the above Newton’s Error
Formula, find a solution for ˆα(n) in terms of xn+1, xn, f ′′(xn) and f′(xn).
You are asked to use the Newton Error Formula [(α−xn+1) = −1
2(α−xn)2f′′(ξn)
f′(xn)] to find an
approximate value ˆα(n) for the true root αby substituting xnfor the unknown ξn. Therefore
(ˆα(n)−xn+1) = −1
2(ˆα(n)−xn)2f′′(xn)
f′(xn).
1
pf3
pf4
pf5

Partial preview of the text

Download Midterm II Solutions for Numerical Analysis for Computing | COT 4501 and more Exams Computer Science in PDF only on Docsity!

Numerical Analysis for Computing

COT 4501

Spring 2005

Midterm II Solutions

April 21, 2009

  1. [35 points] Newton Error Formula: Let f ∈ C^2 (I) be given, for some interval I ⊂ R, with

f (α) = 0 for some α ∈ I. For a given xn ∈ I, define

xn+1 = xn −

f (xn)

f ′(xn)

Then there exists a point ξn between α and xn such that

(α − xn+1) = −

(α − xn)

2 f^

′′(ξ n) f ′(xn)

(a) [5 points] If ξn → α and xn → α as n → ∞, what does the ratio Rn =

α−xn+ (α−xn)^2 converge to?

The ratio Rn =

α−xn+ (α−xn)^2 converges to limn→∞^ Rn^ =^ −^

1 2 limn→∞^

f ′′(ξn) f ′(xn) =^ −^

1 2

f ′′(α) f ′(α).

(b) [5 points] Evaluate Rn (in the limiting case as n → ∞) for f (x) = 2e−βx^ − 1.

For f (x) = 2e−βx^ − 1, f ′(x) = − 2 βe−βx^ and f ′′(x) = 2β^2 e−βx. Therefore, limn→∞ Rn =

− (^12)

f ′′(α) f ′(α) =^

β

(c) [10 points] The Newton Error Formula can be used to approximately “peek ahead” at the

solution f (α) = 0 when we are getting close to convergence. Imagine that you are executing

Newton’s method and are at time step n. You think you are somewhat close to the true answer.

In order to get a better estimate ˆα(n) of the true answer α, you replace ξn by xn in the Newton

Error Formula to get an estimate ˆα(n). Using this approximation in the above Newton’s Error

Formula, find a solution for ˆα(n) in terms of xn+1, xn, f ′′(xn) and f ′(xn).

You are asked to use the Newton Error Formula [(α − xn+1) = − 12 (α − xn)^2

f ′′(ξn) f ′(xn) ] to find an approximate value ˆα(n) for the true root α by substituting xn for the unknown ξn. Therefore

(ˆα(n) − xn+1) = −

(ˆα(n) − xn)^2

f ′′(xn)

f ′(xn)

Define Sn = − (^12)

f ′′(xn) f ′(xn).^ Now

(ˆα(n) − xn+1) = Sn(ˆα(n) − xn)^2

= Sn(ˆα(n)

2 − 2ˆα(n)xn + x

2 n).

Grouping terms, we get

Sn αˆ(n)^2 − (2Snxn + 1)ˆα(n) + (Snx^2 n + xn+1) = 0.

This is a quadratic equation in ˆα(n). Solving for ˆα(n), we get

αˆ(n) =

(2Snxn + 1) ±

√ (2Snxn + 1)^2 − 4 Sn(Snx^2 n + xn+1)

2 Sn

(2Snxn + 1) ±

√ 4 Sn(xn − xn+1) + 1

2 Sn

Defining Tn

def

f (xn) f ′(xn) , we can rewrite the Newton update equation as

xn − xn+1 = Tn

from which we get that

αˆ(n) =

(2Snxn + 1) ±

4 SnTn + 1

2 Sn

It is not clear at this point whether we should take the positive or negative root. It is also not

clear whether 4SnTn + 1 ≥ 0. If the latter is not true, then the estimate ˆα(n) becomes complex

which is unacceptable.

(d) [5 points] Do you think you can actually use the above method to “peek ahead” at the true

solution in an actual application? Discuss.

There are two possible values of ˆα(n), one corresponding to the positive root and the other to

the negative root. If both roots are real, they can both be tested by evaluating f (ˆα(n)). If

|f (ˆα(n))| < |f (xn+1)|, we can use ˆα(n) instead of xn+1 and proceed with Newton’s method.

(e) [10 points] Apply your solution for ˆα(n) to determine |α − αˆ(n)| for f (x) = 2e−βx^ − 1.

For f (x) = 2e−βx^ − 1, Sn = − (^12)

f ′′(xn) f ′(xn) =^

β 2 and^ Tn^ =^

f (xn) f ′(xn) =^

1 − 2 e−βxn 2 βe−βxn^

. From this, we get that

4 SnTn + 1 = 1 −^2 e

−βxn e−βxn^

  • 1 = eβxn^ − 1 > 0 provided βxn > 0. The estimate ˆα(n) is

αˆ(n) =

βxn + 1 ±

eβxn^ − 1

β

= xn +

β

β

√ eβxn^ − 1.

It is still unclear which root to take. The true value α corresponds to f (α) = 0 ⇒ 2 e−βα^ − 1 =

0 ⇒ α =

1 β log 2. The error^ |α^ −^ αˆ(n)|^ =^ |^

1 β log 2^ −^ xn^ −^

1 β ∓^

1 β

eβxn^ − 1 |.

  1. [35 points] Lagrange Interpolation: Consider the function f 1 (x) = |x|. Since this function is not

The value of g(x) at x =

1 2

√ 1+ǫ−

√ ǫ is

g(x) = x −

1 + ǫx^2 +

ǫ(x^2 − 1)

= x − (

1 + ǫ −

ǫ)x

2 −

ǫ

1 + ǫ −

ǫ

1 + ǫ −

ǫ)

[

1 + ǫ −

ǫ]^2

ǫ

1 + ǫ −

ǫ −

1 + ǫ +

ǫ −

ǫ[

1 + ǫ −

ǫ]^2

[

1 + ǫ −

ǫ]^2

1 + ǫ −

ǫ[4(1 + ǫ) + ǫ − 4

√ ǫ(1 + ǫ]

[

1 + ǫ −

ǫ]^2

(4ǫ + 1)

1 + ǫ − (4 + 5ǫ)

ǫ

[

1 + ǫ −

ǫ]^2

At ǫ = 0, g(x) = x − x^2 = 12 − ( 12 )^2 = 14. From symmetry arguments, we get the maximum

error for x = − 1 2

√ 1+ǫ−

√ ǫ

as well. Note that this is valid only for x in the interval [− 1 , 1]. Since

that wasn’t made explicit in the question, the worst error actually occurs for x = ±∞ since

e(x) = ∞.

(e) [10 points] Evaluate the interpolation error E(x) = f 2 (x) − p 2 (x) of the second order Lagrange

interpolation formula at an arbitrary x ∈ [− 1 , 1]? What happens at ǫ = 0? Does the interpola-

tion error formula still hold for ǫ = 0? Discuss. [Please note that you are comparing p 2 (x) with

f 2 (x) =

x^2 + ǫ and not the original function f 1 (x) = |x|.]

E(x) =

√ x^2 + ǫ −

1 + ǫ

x(x − 1)

2

1 + ǫ

x(x + 1)

2

ǫ(x + 1)(x − 1).

At ǫ = 0, the error is

E(x) = |x| − x^2.

Assuming that the interpolation error formula holds, we get at ǫ = 0,

f (x) − pn(x) =

wn(x)

(n + 1)!

f (n+1)(ξx)

x(x − 1)(x + 1)

6

f (3)(ξx)

x(x − 1)(x + 1)

6

[

− 3 ξx

(ξ x^2 + ǫ)

3 2

3 ξ^3 x

(ξ^2 x + ǫ)

5 2

]

for ǫ = 0 because [

− 3 ξx (ξ^2 x +ǫ)

3 2

3 ξ x^3 (ξ^2 x +ǫ)

5 2

] = [− 3 ξ^2 x + 3ξ x^2 ] = 0 at ǫ = 0. This is obviously wrong since

the error for ǫ = 0 is f (x) − p 2 (x) = |x| − x^2 6 = 0 for x 6 = 0. The interpolation error formula

does not hold because

x^2 + ǫ is not C^3 for ǫ = 0.

  1. [30 points] Modification to the Trapezoid rule: The trapezoid rule for constructing an approx-

imation to the definite integral of a function f (x) over the interval [a, b] is based on constructing a

first order Lagrange interpolation to the function f (x) and then integrating the interpolant in the

interval [a, b] to get

T (f ) =

(b − a)

2

(f (b) + f (a)).

(a) [5 points] Construct a first order Lagrange interpolation to an arbitrary function f (x) which

is exact at the points a and b.

p 1 (x) = f (a)

x − b

a − b

  • f (b)

x − a

b − a

(b) [5 points] Integrate the first order Lagrange interpolation of f (x) over the interval [a, b] and

show that you get the above trapezoid rule.

∫ (^) b

a

p 1 (x)dx = f (b)

(b − a)

2

− f (a)

(a − b)

2

f (b) + f (a)

2

(b − a).

(c) [5 points] Now you are given that f (x) = x^2. Do you think the trapezoid rule will be exact for

f (x) = x^2? If not, what is the error of the trapezoid rule for the integral of f (x) = x^2 over the

interval [a, b].

∫ (^) b

a

x

2 dx =

b^3 − a^3

3

The trapezoid rule applied to f (x) = x^2 is

(b^2 + a^2 )

b − a

2

b^3 − a^3 + a^2 b − ab^2

2

The error of the trapezoid rule is therefore

I(f ) − T (f ) =

−b^3 + a^3 − 3 a^2 b + 3ab^2

6

(d) [10 points] How would you modify the trapezoid rule so that it is exact for the integral of

f (x) = x^2 over the interval [a, b]?

The short answer is “Use Simpson’s rule” which is exact not only for second order polynomials

but third order polynomials as well. The long answer is that

∫ (^) b

a

x^2 dx =

b^3 − a^3

3

(b^2 + ab + a^2 )

3

(b − a) =

f (b) +

√ f (b)f (a) + f (a)

3

(b − a).

(e) [5 points] Will your above modification to the trapezoid rule continue to be exact for integrals

of first order polynomials f (x) = αx + β over the interval [a, b]? Discuss.

No. We can prove this by just taking f (x) = x.

∫ (^) b

a

xdx =

b^2 − a^2

2

List of Useful Formulae

Taylor series approximation: f (x) =

∑n i=

(x−x 0 )if (i)(x 0 ) i! +^

(x−x 0 )(n+1)f (n+1)(ξ[x 0 ,x]) (n+1)! with^ ξ[x^0 ,x]^ in the

interval [x 0 , x].

Euler’s method: Approximation of y′^ = f (t, y) is yn+1 = yn + hf (tn, yn) with y 0 = y(t 0 ).

Difference Approximations of Derivatives: f ′(x) =

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

1 2 hf^

′′(ξ x,h),^ f^

′′(x) = f^ (x+h)−^2 f^ (x)+f^ (x−h) h^2 − 1 12 h

(^2) f ′′′′(ξ x,h).

Linear Interpolation formula: p 1 (x) = (^) xx^1 −x 1 −x 0

f (x 0 ) + (^) xx−x^0 1 −x 0

f (x 1 ).

Bisection method: |α − xn| ≤

( 1 2

)n (b − a) with the midpoint of the interval chosen at each step.

Newton’s method: Iterative update to solve f (x) = 0 is xn+1 = xn −

f (xn) f ′(xn) with initial condition^ x^0.

Quadratic formula: Solution of ax^2 + bx + c = 0 is x = −b±

√ b^2 − 4 ac 2 a.

Lagrange interpolation formula: pn(x) =

∑n k=0 f^ (xk)L

(n) k (x) where

L

(n) i (x) =

∏^ n

k = 0

k 6 = i

x − xk

xi − xk

Trapezoid rule: T (f ) =

1 2 (b^ −^ a)(f^ (b) +^ f^ (a)).

Simpson’s rule: S 2 (f ) =

(b−a) 6 (f^ (a) + 4f^ (c) +^ f^ (b)) where^ h^ =^

(b−a) 2 and^ c^ =^

(a+b)

Interpolation Error of Lagrange interpolation: Let f ∈ Cn+1([a, b]) and let the nodes xk ∈ [a, b] for

0 ≤ k ≤ n. Then, for each x ∈ [a, b], there is a ξx ∈ [a, b] such that

f (x) − pn(x) =

wn(x)

(n + 1)!

f

(n+1) (ξx),

where

wn(x) =

∏^ n

k=

(x − xk).

Cubic difference: (b^3 − a^3 ) = (b − a)(b^2 + ab + a^2 ).

Derivatives:

  1. f (0)(x) =

x^2 + ǫ, f (1)(x) = √x x^2 +ǫ

, f (2)(x) = √^1 x^2 +ǫ

− x

2

(x^2 +ǫ)

3 2

, f (3)(x) = −^3 x (x^2 +ǫ)

3 2

  • 3 x

3

(x^2 +ǫ)

5 2

  1. f (0)(x) = 2e−βx^ − 1, f (1)(x) = − 2 βe−βx, f (2)(x) = 2β^2 e−βx.