Midterm Exam Solutions - Numerical Analysis | MATH 128A, Exams of Mathematical Methods for Numerical Analysis and Optimization

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

Typology: Exams

Pre 2010

Uploaded on 10/01/2009

koofers-user-8lz
koofers-user-8lz 🇺🇸

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
MATH 128A, SUMMER 2009, MIDTERM EXAM SOLUTION
BENJAMIN JOHNSON
(1) (8 points) [Calculus]
(a) (4 points) State Taylor’s Theorem.
solution: If f(n+1) exists on [a, b] and x0[a, b], then for every x[a, b] we can write
f(x) as Pn
k=0
f(k)(x)
k!(xx0)k+f(n+1)(c(x))
(n+1)! (xx0)n+1 for some c(x) between x0and x.
[There are other ways to correctly phrase this same theorem].
(b) (4 points) Compute the 3rd Taylor polynomial P3(x) for the function f(x) = sin xabout
the point x0= 0.
solution: P3(x) = f(0)(0)
0! (x0)0+f0(0)
1! (x0)1+f00(0)
2! (x0)2+f000(0)
3! (x0)3.
We have f(0)(x) = f(x) = sin x,f0(x) = cos x,f00(x) = sin x, and f000 (x) = cos x. So
f(0)(0) = 0, f0(0) = 1, f00 (0) = 0, and f000 (0) = 1. So P3(x) = 0 +x+0+ 1
6x3=xx3
6.
(2) (8 points) [Equations in one variable]
(a) (4 points) Explain why the problem of finding solutions for a general equation in one
variable, of the form lhs(x) = rhs(x), is equivalent in difficulty to the problem of finding
the roots of a general function f. [Hint: to show equivalence in difficulty you need to
demonstrate how you would solve one type of problem given a way to solve the other
type of problem, and vice versa.]
solution: Given a general equation of the form lhs(x) = rhs(x), we can define f(x) =
lhs(x)rhs(x). Then to find solutions to the general equation, we just need to define
this fand then find its roots.
Conversely, the equation f(x) = 0 is already in the form of a general equation by
considering lhs(x) = f(x) and rhs(x) = 0. So we can find roots if we can solve general
equations.
(b) (4 points) Explain why the root-finding problem is equivalent in difficulty to the fixed-
point-finding problem.
solution: Given a function fwhose root we want to find, we can define g(x) = xf(x).
Then we can find the roots of fby finding the fixed points of g.
Conversely, if we have a function gwhose fixed points we want to find, we can define
f(x) = xg(x). Then we can find the fixed points of gby finding the roots of f.
(3) (12 points) [Newton’s and Steffensen’s Methods]
(a) (6 points) Let f(x) = x21. Compute the first three terms generated by applying
Newton’s method to fstarting with p0= 2, (counting p0, so you just need to compute
through p2).
solution: We use the equation pn=pn1f(pn1)
f0(pn1).
Since f0(x) = 2x, we have p1= 2 221
2·2= 2 3
4=5
4.
Then p2=5
4(5/4)21
2·(5/4) =5
4(25/16)1
(10/4) =5
49/16
10/4=5
49
40 =41
40 .
Date: July 16, 2008.
1
pf3
pf4

Partial preview of the text

Download Midterm Exam Solutions - Numerical Analysis | MATH 128A and more Exams Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

MATH 128A, SUMMER 2009, MIDTERM EXAM SOLUTION

BENJAMIN JOHNSON

(1) (8 points) [Calculus] (a) (4 points) State Taylor’s Theorem. solution: If f (n+1)^ exists on [a, b] and x 0 ∈ [a, b], then for every x ∈ [a, b] we can write f (x) as

∑n k=

f (k)(x) k! (x^ −^ x^0 )

k (^) + f^ (n+1)(c(x)) (n+1)! (x^ −^ x^0 )

n+1 (^) for some c(x) between x 0 and x. [There are other ways to correctly phrase this same theorem]. (b) (4 points) Compute the 3rd Taylor polynomial P 3 (x) for the function f (x) = sin x about the point x 0 = 0. solution: P 3 (x) = f^

(0)(0) 0! (x^ −^ 0)

(^0) + f^ ′(0) 1! (x^ −^ 0)

(^1) + f^ ′′(0) 2! (x^ −^ 0)

(^2) + f^ ′′′(0) 3! (x^ −^ 0)

We have f (0)(x) = f (x) = sin x, f ′(x) = cos x, f ′′(x) = − sin x, and f ′′′(x) = − cos x. So f (0)(0) = 0, f ′(0) = 1, f ′′(0) = 0, and f ′′′(0) = −1. So P 3 (x) = 0+x+0+ − 61 x^3 = x− x

3

(2) (8 points) [Equations in one variable] (a) (4 points) Explain why the problem of finding solutions for a general equation in one variable, of the form lhs(x) = rhs(x), is equivalent in difficulty to the problem of finding the roots of a general function f. [Hint: to show equivalence in difficulty you need to demonstrate how you would solve one type of problem given a way to solve the other type of problem, and vice versa.] solution: Given a general equation of the form lhs(x) = rhs(x), we can define f (x) = lhs(x) − rhs(x). Then to find solutions to the general equation, we just need to define this f and then find its roots. Conversely, the equation f (x) = 0 is already in the form of a general equation by considering lhs(x) = f (x) and rhs(x) = 0. So we can find roots if we can solve general equations. (b) (4 points) Explain why the root-finding problem is equivalent in difficulty to the fixed- point-finding problem. solution: Given a function f whose root we want to find, we can define g(x) = x−f (x). Then we can find the roots of f by finding the fixed points of g. Conversely, if we have a function g whose fixed points we want to find, we can define f (x) = x − g(x). Then we can find the fixed points of g by finding the roots of f. (3) (12 points) [Newton’s and Steffensen’s Methods] (a) (6 points) Let f (x) = x^2 − 1. Compute the first three terms generated by applying Newton’s method to f starting with p 0 = 2, (counting p 0 , so you just need to compute through p 2 ). solution: We use the equation pn = pn− 1 − (^) ff ′((ppnn−−^11 )). Since f ′(x) = 2x, we have p 1 = 2 − 2

(^2) − 1 2 · 2 = 2^ −^

3 4 =^

5

Then p 2 = 54 − (5/4)

(^2) − 1 2 ·(5/4) =^

5 4 −^

(25/16)− 1 (10/4) =^

5 4 −^

9 / 16 10 / 4 =^

5 4 −^

9 40 =^

41

Date: July 16, 2008. 1

2 BENJAMIN JOHNSON

(b) (6 points) Let g(x) = (^1) x. List the first five terms of the sequence generated by applying Steffensen’s method to g, starting with p 0 = 2, (counting p 0 , so you just need to compute up through p 4 ). solution: Steffensen’s method uses a combination of fixed point iteration and Aitken’s ∆^2 method. We have p 1 = g(p 0 ) = 12. Then p 2 = g(p 1 ) = (^11) / 2 = 2. Then p 3 = p 0 − (p^1 −p^0 )

2 p 2 − 2 p 1 +p 0 = 2^ −^

(1/ 2 −2)^2 2 − 2 ·(1/2)+2 = 2^ −^

9 / 4 3 = 2^ −^

3 4 =^

5

  1. Then finally,^ p^4 =^ g(p^3 ) =^

4

(4) (8 points) [Zeros of Polynomials] (a) (4 points) State the Fundamental Theorem of Algebra. solution: Every polynomial with coefficients in C has at least one root in C. (b) (4 points) Explain how M¨uller’s method works. You may use graphs and pictures, but you must explain the method in words. solution: M¨uller’s method works like the secant method, but with three points and a parabola instead of two points and a line [a picture would help to illustrate this]. As far as the method goes, start with p 0 , p 1 , p 2 ; find the unique degree 2 (or less) polynomial that passes through these points; then find a root of this polynomial that is closest in distance to p 2. Call this root p 3. Repeat the procedure with p 1 , p 2 , p 3 in place of p 0 , p 1 , p 2. Continue in this manner until you reach a maximum number of steps or you achieve the proper tolerance for |pn − pn− 1 |. BONUS: (4 points) Aside from convergence properties, what additional advantage does M¨uller’s method have over all the the other root-approximating methods presented in chapter 2 of the textbook. solution: The method will find complex roots even if you start with purely-real initial values. (5) (8 points) [Lagrange Polynomial] (a) (4 points) Let f be a function defined at some real numbers x 0 ,... , xn. Give a defining equation for the Lagrange Interpolating Polynomial for f over x 0 ,... , xn.

solution: Pn(x) =

∑n k=0 f^ (xk)^

∏n i=0,i 6 =k

x−xi xk −xi

(b) (4 points) Let f (x) = cos x and for i ∈ { 0 , 1 , 2 }, let xi = i· 2 π. Write an expression for the Lagrange interpolating polynomial for f over x 0 , x 1 , x 2. solution: P 2 (x) = cos(0)((0x−−π/π/2)(2)(0x−−ππ)) + cos(π/2) (^) (π/(x 2 −−0)(0)(xπ/− 2 π−)π) + cos π ((πx−−0)(0)(xπ−−π/π/2)2) = (x−π/ π2)( (^2) / 2 x −π)+ 0 − x((xπ− (^2) /π/2)2) = −π( πx 2 −/π/ 2 2)= (^) π− 2 πx/ 2 + 1 = 1 − (^2) πx.

(6) (10 points) [Cubic Spline Interpolation] (a) (4 points) Suppose that a = x 0 < x 1 < · · · < xn = b, that f is define at xj for each j, and that f is differentiable at a and b. Define what it means for S to be a clamped cubic spline interpolant for f over the nodes x 0 ,... xn. solution: It means that

  1. Sj :≡ S|[xj ,xj+1] can be expressed as a polynomial of degree at most 3 (for j = 0 ,... n − 1), and
  2. Sj (xj ) = f (xj ) and Sj (xj+1) = f (xj+1) for j = 0,... n − 1, and
  3. Sj (xj+1) = Sj+1(xj+1) for j = 0,... , n − 2, and
  4. S j′ (xj+1) = S j′+1(xj+1) for j = 0,... , n − 2, and
  5. S j′′ (xj+1) = S j′′+1(xj+1) for j = 0,... , n − 2, and

4 BENJAMIN JOHNSON

(b) (4 points) State Simpsons’ rule (with or without the error term). solution:

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

b−a 6

[

f (a) + 4f

(a+b 2

  • f (b)

]

[You can also express the same rule using different notation]. (c) (4 points) Give an example of another formula different from the ones in parts (a) and (b) that can be used to approximate the definite integral

∫ (^) b a f^ (x)dx. solution: One example is the midpoint rule:

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

(a+b 2

, but there are a number of other possibilities. (9) (10 points) [Romberg Integration] (a) (4 points) Your textbook uses the notation Rk, 1 to denote one particular approximation of

∫ (^) b a f^ (x)dx.^ Please explain how^ Rk,^1 relates to the composite trapezoid rule.^ To receive full credit, you must specify all the required parameters (h, n, the xj ’s, etc... ) necessary to apply the composite trapezoid rule. solution: Rk, 1 uses the composite trapezoid rule with n = 2k−^1 , h = hk = 2 bk−−a 1 , and xj = a + j · hk for each j = 0,... 2 k−^1. [You can get full credit for this question by drawing an appropriate picture with all the labels correct.] (b) (6 points) Use Romberg integration to compute R 2 , 2 for the integral

0 e

x^2 dx. You do not need to compute any decimals. Just leave your answer in a form that includes some e’s in it. solution: We compute R 1 , 1 using the trapezoid rule and we compute R 2 , 1 using the composite trapezoid rule with three equally spaced points. For R 2 , 2 we use Richardson’s extrapolation. R 1 , 1 = 1 − 2 0 [e^1 2

  • e^0 2 ] = e+1 2. R 2 , 1 = 0.^52 − 0 [e(0.5) 2
  • e^0 2 ] + 1 − 20.^5 [e(0.5) 2
  • e^1 2 ] = 0.25[e^0.^25 + 1] + 0.25[e^0.^25 + e] = 0.25 +
  1. 5 e^0.^25 + 0. 25 e. R 2 , 2 = 4 R^2 ,^13 − R^1 ,^1 = 4[0.25+0. 5 e^0.^25 +0. 25 e]− e+1 2 3 =^

1+2e^0.^25 +e− e 2 − (^12) 3 =^

1+4e^0.^25 +e