

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


CMSC/MAPL 460 Dr. Wolfe ASSIGNMENT #1 Due February 19, 2001
Assume β = 2. What can you infer about the machine constants t, U and L? (The last two constants are called M and m in Shampine et al.)
ln(1 − x) + xex/^2 x^3
Use MATLAB to compute f (x) for x = 10−m, m = 1, 2 , · · · , 12. According to the theory what is limx→ 0 f (x)? For x near zero what is a better way to compute f (x) ? (Hint: Use Taylor’s theorem on the numerator.)
x + 2 −
x be computed accurately when x is large?
Define machine multiplication x ⊗ y similarly. For example,
Constuct examples to show that, in general, the following statements are not true: (a) (x ⊕ y) ⊕ z = x ⊕ (y ⊕ z), (b) (x ⊗ y) ⊗ z = x ⊗ (y ⊗ z), (c) x ⊗ (y ⊕ z) = (x ⊗ y) ⊕ (x ⊗ z).
erf(x) =
π
∫ (^) x
0
exp(−t^2 ) dt.
The integral cannot be expressed in terms of more elementary functions. It is a library function in MATLAB. The Taylor series for the error function is
erf(x) =
π
n=
(−1)nx^2 n+ n!(2n + 1)
The series converges for all x. Write a MATLAB function m-file to evaluate erf(x) using this series. Use as many terms in the series as are necessary so that the first neglected term does not alter the accumulated sum when it is added to it in floating point arithmetic. Since this is an alternating series, the error caused by truncating the infinite sum will then be less than the roundoff error. Investigate the effect of roundoff error by comparing the computed sum with the value given by the MATLAB function erf. Try x = 0. 5 , 1. 0 , 2. 0 , 5. 0 , 7. 0 , 10 .0. Explain your results. Hint: The main loop of your program might look like this: while s ∼= so so = s; n = n + 1; t = −xsq ∗ t ∗ (2. 0 ∗ n − 1 .0)/(n ∗ (2 ∗ n + 1)); s = s + t; end What values should be assigned to t, n, s and xsq before entering the loop? Do not forget the factor 2/
π.