Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

MATH256  Problem Sheet 4

4.1   (a)  Compute the relative error in the approximation π ≈ 355/113. What does this tell you about the number of correct significant figures in the approximation?  How many correct significant gures does it actually have?

Use an accurate value for π provided by Maple (or your calculator) in place of the exact value.

(b)  Compute the relative errors that occur when the following quantities are approximated using ten significant figures:

(i)   π,        (ii)   355/113.

Hint: set Digits to 16, and then use evalf[10](  . . .    ) to obtain ten digit approximations.

(c)  Suppose that

d = π - 355/113

is computed on a machine that uses ten digit arithmetic.  Use the formula

from example 2.4.3 to estimate the relative error in the approximation to d.  How many correct significant gures should you expect?

(d)  Evaluate d, then set Digits back to 10, and evaluate it again.  How many significant figures are correct in the second result?

(e)   (i)  Count the number of digits displayed by your calculator. How many correct significant figures do you expect if d is computed using this device?

(ii)  Compute d using your calculator.  How many signicant gures are

correct? Why do you think this happens?

(iii) What approximation is your calculator using for π? Can you think of a way to prove this?

4.2  Let  and y˜ be approximations to x and y with relative errors εx  and εy , respectively.  Using the method of §2.4, calculate the relative error in the following quantities, and in each case state whether a significant magnification of the error has occurred.

(a) y˜,

(b)  1/y˜ .   (Hint: use a Taylor series.)

4.3   (a)  Let  be an approximation to x with relative error εx . Find the relative error in ln  . Is there a risk of catastrophic cancellation?

(Hint: use a Taylor series.)

(b) Suppose now that x = π/3 and  = 1.047. Compute

(i) The relative error in  .

(ii) The relative error in ln  predicted by the formula from part (a). (iii) The actual relative error in ln  .

4.4  Let X1  = x1 + iy1  and X2  = x2 + iy2 .  Suppose that j  = j  + iy˜j  is an approximation to Xj , with

j  = xj (1 + εxj )   and   y˜j  = yj (1 + εyj )

(a)  Calculate the magnitude of relative error in j  in terms of εxj   and εyj . (b)  Calculate the relative error in 1 + 2  in terms of xj , yj , εxj    and εyj .

Under what circumstances is there a risk of catastrophic cancellation?

4.5 Suppose that

X1 = 0.5 - i,                 1 = 0.5 - 1.0001i,

X2 = 1 + 2.001i   and   2 = 1 + 2.00102i.

(a)  Calculate the magnitudes of the relative errors in 1 , 2  and 1 2 .       (b)  How many correct significant gures does the imaginary part of 1 2

have? Why does this happen?

4.6 Suppose that lxl < 1, so that ex  ≈ 1. Computing ex - 1 by nding ex  and then subtracting 1 is then at risk of catastrophic cancellation. Suggest two methods by means of which ex  - 1 can be evaluated without the risk of cancellation.

4.7  Let

f (北) = 北 ^2 + 1 - ^2 - 1 .

(a)  Using Taylor series, show that f (北) → 1 as → o.

(b)  Evaluate f (10n  * π), for n  = 6, 7, 8, 9 and  10.   If you  use  Maple (recommended), set Digits to 16, and make sure you use evalf to obtain numerical answers.  Do the results agree with your answer to part (a)? Why do you think this happens?

(c)  Find an expression for f (北) that can be used to produce accurate results for large 北.   Repeat the calculations from part (b) using your new expression.

Hint: consider the product

^2 + 1 - ^2 - 1^2 + 1 +^2 - 1 .

4.8 Throughout this question, Kn  is dened as

Kn =  01 北2n sin(π北) d北,    n = 1, 2, . . .

Where necessary, check your results using the function

K_ex  := n  ->  evalf[32](  Int( x^(2*n)  *  sin(  Pi  * x  )  ,    x  =  0  . .  1  )  )  :

(a) Write a do loop that computes the sequence K1 , K2 . . . from K0  using forward recurrence. Compute the relative errors in K1 , . . . , K16 .

How  many digits  must  be stored  in order to guarantee one correct

significant gure in K100 ?  (You may need to use trial and error to determine this.)

(b)  Using integration by parts, or otherwise, show that

Kn+1 =  π - (2n + 1)(2n + 2)Kn] .

(c)  Use the method of example 2.7.1 to determine the effect that using the recurrence relation in part b to compute Kn+1  from Kn  has on the magnitude of an existing error in Kn .

(d)  Explain how Miller’s algorithm can be used to compute the sequence of integrals Kn  for n = 1, . . . , N .  In particular, how should the starting point for the recurrence be determined?

(e)  Write a Maple procedure that computes Kn  using Miller’s algorithm .

The procedure should take as its argument a nonnegative integer N ,

and return an array containing accurate values for K0 , . . . , KN .  Test your procedure against results provided by the function Kex .