Docsity

Final Exam Solution Key - Numerical Computing - Fall 2002 | MATH 4800, Exams of Mathematics

Toggle sidebar
bg1
NUMERICAL COMPUTING
FINAL EXAMINATION
December 17, 2002
NAME (print)
NOTES
1. Please make sure that your test package consists of 11 pages.
2. Do any five problems, as long as these include at least one of the last two. In the table
below, cross out the numbers of the two problems 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
5
6
7
TOTAL
1
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Final Exam Solution Key - Numerical Computing - Fall 2002 | MATH 4800 and more Exams Mathematics in PDF only on Docsity!

NUMERICAL COMPUTING

FINAL EXAMINATION

December 17, 2002

NAME (print)

NOTES

  1. Please make sure that your test package consists of 11 pages.
  2. Do any five problems, as long as these include at least one of the last two. In the table below, cross out the numbers of the two problems 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. Consider the base -10, normalized, floating-point system defined by

(0.d 1 d 2 d 3 d 4 )10n,

where the integer n lies in the interval [− 3 , 2].

(a) Define the terms underflow limit, overflow limit and machine epsilon for a floating-point number system, and find their values in the present case. (b) If x and y are two adjacent numbers in the given system, then what are the largest and smallest values of |x − y|? (c) Can the number 31/3 be represented precisely in the system? If not, then what nearest floating- point number will represent it, assuming chopping? (d) Consider the divergent series ∑∞

k=

k

Explain why summing this series in a floating-point system results in a finite sum? At what point will the partial sums cease to change in the present system?

(a) Underflow limit is the smallest number, and overflow limit the largest number in the floating-point system. Machine epsilon is the separation between the number 1 and the next larger number. Machine epsilon is a measure of the relative separation between numbers. Here, U F L = (0.1000)10−^3 = 10−^4 , OF L = (0.9999)10^2 = 99. 99 , mach = (0.1001)10 − (0.1000)10 = (0.0001)10 = 10−^3. (b) |x − y|max = (0.9999)10^2 − (0.9998)10^2 = (0.0001)10^2 = 0. 01.

|x − y|min = (0.1001)10−^3 − (0.1000)10−^3 = (0.0001)10−^3 = 10−^7. (c) 31 /3 = 10. 3333... has the machine representation (0.1033)10^2. (d) The sum is finite because once the next number to be added becomes smaller than mach times the current partial sum, the partial sum does not change. In the present case, this will happen at the level N where 1 N < mach

N∑ − 1

k=

k

  1. (a) Explain the terms partial pivoting and complete pivoting in the context of Gaussian elimination.

(b) Using partial pivoting if necessary, use Gaussian elimination to solve the system    

x 1 x 2 x 3 x 4

Be sure to show all steps.

(a) Gaussian elimination, when applied to the linear system Ax = b, reduces it to Lx = y where L is lower triangular. At stage k of the elimination process, the diagonal entry in the (k, k) position is chosen as the pivot. Because the process involves division by the pivot, it is advantageous to have the pivot possessing the largest possible numerical value. In partial pivoting one scans the kth column, identifies the row that has the largest element in that column, and swaps that row with the k th row. In complete pivoting one scans the entire submatrix to the right and below the (k, k) position, and swaps rows and columns to bring the largest entry in that submatrix to the (k, k) position. (b) Consider the augmented matrix    

The operations 0. 5 R 2 − R 1 , R 3 − R 1 , R 4 − R 1 lead to    

Upon swapping R 2 and R 3 , we get    

Now swapping R 3 and R 4 ,    

The operation R 4 + 0. 25 R 3 gives    

Back substitution now gives

x 4 = 2, x 3 = 2, x 2 = 3, x 1 = − 7.

  1. (a) Suppose you are given the following information about a smooth function:

f (− 0 .2) = 2, f (0) = 1. 8 , f (0.2) = 1. 9.

Use these values to compute the best numerical approximations you can to f ′(0) and f ′′(0). Justify the formulas you use, and state the order of accuracy of each approximation. (b) Let the integral

∫ (^3) h 0 f^ (x)^ dx^ be approximated by the quadrature formula

Q = a 0 f (0) + a 1 f (h) + a 2 f (2h).

Determine the ai in order to maximize the precision of the formula.

(a) Consider the Taylor series

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

h^2 2

f ′′(0) +

h^3 6

f ′′′(0) +

h^4 24

f iv^ (0) + · · · ,

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

h^2 2 f ′′(0) −

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

h^4 24 f iv^ (0) + · · ·.

The following formulas emerge:

f ′(0) = f (h) − f (−h) 2 h

  • O(h^2 ),

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

  • O(h^2 ).

With h = 0. 2 , f (−h) = 2, f (0) = 1. 8 , f (h) = 1. 9 , we get the approximations

f ′(0) = − 0. 25 , f ′′(0) = 7. 5.

(b) Requiring exactness for f (x) = 1, x, x^2 , we get ∫ (^3) h

0

1 dx = 3 h = a 0 + a 1 + a 2 , ∫ (^3) h

0

x dx =

9 h^2 2

= a 1 h + a 22 h, ∫ (^3) h

0

x^2 dx = 9 h^3 = a 1 h^2 + a 24 h^2.

These lead to a 0 = 3h/ 4 , a 1 = 0, a 2 = 9h/ 4.

  1. Consider the initial-value problem for the ODE

dy dt

= f (t, y), y(0) = a,

and the following algorithm designed to obtain its numerical solution:

yk+1 = yk +

h 2

[

3 f (tk, yk) − f (tk− 1 , yk− 1 )

]

Here h is the step size, tk = kh, and yk is the numerical approximation to y(tk).

(a) State whether the numerical algorithm is (i) implicit or explicit, and (ii) single-step or multistep. (b) Define the term local truncation error in the context of numerical algorithms for solving ODEs. If this error is O(hp) for the above algorithm, then find the value of p. Here Taylor series may be useful. (c) For the case dy dt

= t + ey

2 , y(0) = 0,

use the above algorithm to find an expression for y(2h). Be sure that your expression only involves known quantities. (If this requires a starting procedure, make sure that this procedure preserves the accuracy of the algorithm.)

(a) The algorithm is explicit and multistep (2-step). (b) The local truncation error measures the error made in one step of the algorithm. Let us assume that yk and yk− 1 are exact, i.e., yk = y(tk), yk− 1 = y(tk − h). Then the local truncation error `k+1 can be defined as the difference between the approximation yk+1 computed from the algorithm and the exact solution y(tk + h), i.e.,

`k+1 = yk+1 − y(tk + h).

Here,

`k+1 = yk+1 − y(tk + h)

= y(tk) + h 2

[

3 f (tk, y(tk)) − f (tk − h), y(tk − h))

]

− y(tk + h). (1)

To find the order of this error, we expand the various quantities on the RHS in Taylor series about t = tk. Thus,

y(tk + h) = y(tk) + hy′(tk) +

h^2 2!

y′′(tk) + O(h^3 ),

f (tk − h, y(tk − h)) = f (tk, y(tk)) − h

∂f (tk, y(tk)) ∂t

∂f (tk, y(tk)) ∂y

y′(tk)

  • O(h^2 )

= y′(tk) − hy′′(tk) + O(h^2 )

Substitution in (1) leads to

`k+1 = y(tk) + h 2

[

3 y′(tk) − y′(tk) + hy′′(tk) + O(h^2 )

]

− y(tk) − hy′(tk) − h^2 2!

y′′(tk) + O(h^3 )

= O(h^3 ).

Thus the error is O(hp) with p = 3.

(c) Here, y′(t) = f (t, y) ≡ t + ey

2 , and y(0) = 0. According to the algorithm,

y(2h) = y(h) +

h 2

[

3 f (h, y(h)) − f (0, y(0))

]

We do not know what y(h) is, and for consistency, we need to estimate it to the same accuracy as the algorithm. We can do that, for example, by the Taylor method

y(h) = y(0) + hy′(0) +

h^2 2!

y′′(0).

Note that y′′(t) =

d dt

y′(t) =

d dt

[t + ey

2 ] = 1 + ey

2 2 yy′

Therefore,

y′(0) = 0 + exp{y(0)} = 1, y′′(0) = 1 + exp{y^2 (0)} 2 y(0)y′(0) = 1,

leading to y(h) = h +

h^2 2

Also, then, f (0, y(0)) = 1, f (h, y(h)) = h + exp [{h + h^2 / 2 }^2 ]. Finally,

y(2h) = h +

h^2 2

h 2

[

3 h + 3 exp [{h + h^2 / 2 }^2 ] − 1

]

h 2

  • 2h^2 + 3 h 2

exp [{h + h^2 / 2 }^2 ].

so that

ci =

− 1 f^ (x)φi(x)^ dx ∫ (^1) − 1 ci{φi(x)}

(^2) dx

Evaluating various integrals, (^) ∫ 1

− 1

φ^21 (x) dx =

− 1

dx = 2,

∫ (^1)

− 1

φ^22 (x) dx =

− 1

x^2 dx = 2/ 3 ,

∫ (^1)

− 1

φ^23 (x) dx =

− 1

x^4 −

2 x^3 3

dx = 8/ 45 ,

∫ (^1)

− 1

φ 1 (x)f (x) dx =

− 1

1 + x^2

dx = π/ 2 ,

∫ (^1)

− 1

φ 2 (x)f (x) dx =

− 1

x 1 + x^2

dx = 0,

∫ (^1)

− 1

φ 3 (x)f (x) dx =

− 1

x^2 − 1 / 3 1 + x^2

dx = 2 − 2 π/ 3.

Then, c 1 = π/ 4 , c 2 = 0, c 3 = 45(1 − π/3)/ 4.