Docsity

Exam 2 with Answer Key - Numerical Computing | MATH 4800, Exams of Mathematics

Toggle sidebar
bg1
NUMERICAL COMPUTING
TEST II
November 22, 2002
NAME (print)
NOTES
1. Please make sure that your test package consists of 7 pages.
2. Do any three problems. In the table below, cross out the number of the problem you do not wish
to be graded.
3. In order to receive full credit, your work MUST be accompanied by appropriate explanatory statements,
written in comprehensible English.
4. The test is closed-book and closed-notes.
5. Best wishes.
1
2
3
4
TOTAL
1
pf3
pf4
pf5

Partial preview of the text

Download Exam 2 with Answer Key - Numerical Computing | MATH 4800 and more Exams Mathematics in PDF only on Docsity!

NUMERICAL COMPUTING

TEST II

November 22, 2002

NAME (print)

NOTES

  1. Please make sure that your test package consists of 7 pages.
  2. Do any three problems. In the table below, cross out the number of the problem you do not wish to be graded.
  3. In order to receive full credit, your work MUST be accompanied by appropriate explanatory statements, written in comprehensible English.
  4. The test is closed-book and closed-notes.
  5. Best wishes.

TOTAL

  1. (a) Find the three Lagrange polynomials of degree 2 for interpolation over the points x 1 = 0, x 2 = 1 , x 3 = 2. (b) Use the result of part (a) to find the quadratic interpolant to f (x) = 6/(x + 1) on the interval [0, 2]. (c) What advantage does Lagrange interpolation have over monomial interpolation and Newton in- terpolation? (d) In interpolating a smooth function over a large number of nodes, what is the advantage of piecewise polynomial interpolation over interpolation by a single polynomial? Explain. (e) Give a short description of interpolation by cubic splines.

(a) The three Lagrange polynomials are

L 1 (x) =

(x − x 2 )(x − x 3 ) (x 1 − x 2 )(x 1 − x 3 )

=

(x − 1)(x − 2) (0 − 1)(0 − 2)

x^2 − 3 x + 2 2

L 2 (x) =

(x − x 1 )(x − x 3 ) (x 2 − x 1 )(x 2 − x 3 )

=

(x − 0)(x − 2) (1 − 0)(1 − 2)

= −x^2 + 2x,

L 3 (x) =

(x − x 1 )(x − x 2 ) (x 3 − x 1 )(x 3 − x 2 )

=

(x − 0)(x − 1) (2 − 0)(2 − 1)

x^2 − x 2

(b) The quadratic interpolant is

F (x) = f (0)L 1 (x) + f (1)L 2 (x) + f (2)L 3 (x)

= 6

x^2 − 3 x + 2 2

  • 3(−x^2 + 2x) + 2

x^2 − x 2 = x^2 − 4 x + 6.

(c) The weights are the easiest to compute for Lagrange interpolation. (d) The error associated with a single polynomial of high degree can be large, especially near the end points over the interval. Piecewise polynomial interpolation avoids this problem. (e) Cubic spline interpolation is a form of piecewise polynomial interpolation in which the piecewise polynomials are cubics. Continuity of the interpolant, and of its first and second derivatives, is enforced at each node.

  1. The n -point formula for a numerical approximation to the integral

I =

− 1

f (x) dx

takes the form Qn =

∑^ n

i=

cif (xi),

where the xi are the nodes and the ci the corresponding weights. The nodes lie in the interval [− 1 , 1], and obey − 1 ≤ x 1 < x 2 < · · · < xn− 1 < xn ≤ 1. (a) How does the node placement differ between Newton-Cotes quadrature and Gaussian quadrature? Which would you expect to be more accurate for the same number of nodes and why? (b) Take n = 3 and derive a closed Newton-Cotes formula. (c) Take n = 2 and derive a Gaussian formula.

(a) In Newton-Cotes quadrature the nodes are equally spaced, whereas in Gaussian quadrature they are optimally chosen for maximum accuracy. (b) For n = 3 the nodes for a closed formula are -1, 0 and 1. Then the approximation takes the form Q 3 = c 1 f (−1) + c 2 f (0) + c 3 f (1). The weights are derived by requiring that the formula be exact for f = 1, f = x and f = x^2. Then,

c 1 + c 2 + c 3 =

− 1

1 dx = 2,

−c 1 + c 3 =

− 1

x dx = 0,

c 1 + c 3 =

− 1

x^2 dx =

The solution of this linear system is c 1 = c 3 = 1/ 3 , c 2 = 4/ 3 , leading to the formula

Q 3 =

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

(c) Let the two nodes be x 1 and x 2. Then the approximation is G 2 = c 1 f (x 1 ) + c 2 f (x 2 ). The nodes and the weights are derived by requiring exactness for the polynomials 1, x, x^2 and x^3. Then,

c 1 + c 2 =

− 1

1 dx = 2,

c 1 x 1 + c 2 x 2 =

− 1

x dx = 0,

c 1 x^21 + c 2 x^22 =

− 1

x^2 dx =

c 1 x^31 + c 2 x^32 =

− 1

x^3 dx = 0.

The relevant solution is c 1 = c 2 = 1, −x 1 = x 2 = 1/

  1. The formula becomes

G 2 = f (− 1 /

    • f (1/
  1. (a) Given a sufficiently smooth function f (x), use Taylor series to derive a second-order accurate, one-sided difference approximation to f ′(x) in terms of the values f (x), f (x + h) and f (x + 2h). If the approximation is denoted by F (x, h), then show that

f ′(x) = F (x, h) + ah^2 + bh^3 + · · · ,

where a, b, · · · are functions of x. (b) Suppose that for a particular value of x, F = 0.8500 for h = 0.2 and F = 0.9000 for h = 0. 1. Use Richardson’s extrapolation to compute an improved approximation.

(a) Consider the Taylor series

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

h^2 2 f ′′(x) +

h^3 6 f ′′′(x) +

h^4 24 f iv^ (x) + · · ·

f (x + 2h) = f (x) + 2hf ′(x) + 4 h^2 2

f ′′(x) + 8 h^3 6

f ′′′(x) + 16 h^4 24

f iv^ (x) + · · ·.

Upon elimination of f ′′(x) we get

f (x + 2h) − 4 f (x + h) = − 3 f (x) − 2 hf ′(x) +

4 h^3 6

f ′′′(x) +

12 h^4 24

f iv^ (x) + · · · ,

whence f ′(x) = 4 f (x + h) − 3 f (x) − f (x + 2h) 2 h

h^2 3

f ′′′(x) + h^3 4

f iv^ (x) + · · ·.

Thus the approximation formula is

F (x, h) = 4 f (x + h) − 3 f (x) − f (x + 2h) 2 h and we can write f ′(x) = F (x, h) + ah^2 + bh^3 + · · · , where a =

f ′′′(x), b =

f iv^ (x).

(b) We have

f ′^ = 0 .8500 + a(0.2)^2 + b(0.2)^3 , f ′^ = 0 .9000 + a(0.1)^2 + b(0.1)^3.

Elimination of a leads to the improved result

f ′^ =

Worksheet