Numerical Analysis I, Fall 2017 (http://www.math.nthu.edu.tw/˜ wangwc/)

Quiz 01

Sep 26, 2017.

1. (30 pts) How many bits does it take to store a binary floating point number of the form ±1.a_{1}a_{2} ⋯ a_{t} × 2^{e} with t = 10, a_{j} ∈ {0, 1}, −14 ≤ e ≤ 15? Write down the binary floating number representation (binary machine number, a finite sequence of 0,

1) of −0.6875. Explain. Leave some spacing between sign and exponent and between exponent and mantissa for easy reading.

Ans:

There are total 30 different exponents (−14 ≤ e ≤ 15). It takes 5 bits to give 30 or more different exponents (2^{5} = 32). Total bits = 1 + 10 + 5 = 16 (15pts).

The range of the 5-bit binary exponent c = (b_{1}b_{2}b_{3}b_{4}b_{5})_{2}, b_{i} = 0, 1, is 0 ≤ c ≤ 31. In order to cover the range −14 ≤ e ≤ 15, one should take e = c − 15, so that e = −15 and e = 16 can be reserved for underflow and overflow, respectively. With e = c − 15, the binary machine number is given by:

−0.6875 = −(1.011)_{2} × 2^{−1} = 1 01110 0110000000 (15 pts)

2. (30 pts) \underline{Derive} an upper bound for relative error caused by chopping for the floating point system in problem 1 (also known as ε_{M}). Give an upper bound in terms of ε_{M} on the relative error of evaluating x × y with the floating point arithmetics.

Ans:

\frac{|x − fl_{chop}(x)|}{|x|} = |\frac{0.0 … 0a_{t+1} … × 2^{e}}{1.a_{1} … a_{t+1} … × 2^{e}} |
= |\frac{0.a_{t+1} …}{1.a_{1} … a_{t+1} …}| × 2^{−t}
≤ |\frac{1}{1}| × 2^{−t} = 2^{−t} = 2^{−10} (15 pts)

\frac{|x × y − fl(fl(x) ⊗ fl(y))|}{|x × y|} = |\frac{x × y − (x(1 + δ_{1}) × y(1 + δ_{2}))(1 + δ_{3})}{x × y}|
≈ |\frac{x × y − x × y(1 + δ_{1} + δ_{2} + δ_{3})}{x × y}|
≤ |δ_{1}| + |δ_{2}| + |δ_{3}| ≤ 3ϵ_{M} (15 pts)

3. (20 pts) Solve for x^{2} − 2100x + 1 = 0 to 15 correct digits. Explain how you find your answer (direct evaluation using ’calculator’ will receive no credits).

Ans:

x_{1} = \frac{2100+\sqrt{2100^{2}−4}}{2} = 2.09999952380942e + 03 (5 pts) x_{2} = 1/x_{1} or \frac{2}{2100+\sqrt{2100^{2}−4}} = 4.76190584170225e − 04 (5 pts) Code (10 pts) Extra points by writting C (2 pts)

4. (20 pts) Find the smallest N so that |∑_{i=0}^{N} \frac{3^{i}}{i!} − e^{3}| < 10^{−5}. Let your code print the

answer N and |∑_{i=0}^{N} \frac{3^{i}}{i!} − e^{3}| on screen, and also write them down on the answer sheet.

Extra credits for more efficient method(s).

Ans:

N=15 (5 pts) absolute error = 2.49221685777457e-06 (“format short” is ok.) (5 pts) Code (10 pts) Extra points by writting C (2 pts) Extra points by nested summation (4 pts)

Name your codes in the same format as 104000001 p03.m or 103000002 p04.c .

Numerical Analysis I, Fall 2017 (http://www.math.nthu.edu.tw/˜ wangwc/)

Quiz 01

Sep 26, 2017.

1. (30 pts) How many bits does it take to store a binary floating point number of the form ±1.a_{1}a_{2} ⋯ a_{t} × 2^{e} with t = 10, a_{j} ∈ {0, 1}, −14 ≤ e ≤ 15? Write down the binary floating number representation (binary machine number, a finite sequence of 0,

1) of −0.6875. Explain. Leave some spacing between sign and exponent and between exponent and mantissa for easy reading.

2. (30 pts) \underline{Derive} an upper bound for relative error caused by chopping for the floating point system in problem 1 (also known as ε_{M}). Give an upper bound in terms of ε_{M} on the relative error of evaluating x × y with the floating point arithmetics.

3. (20 pts) Solve for x^{2} − 2100x + 1 = 0 to 15 correct digits. Explain how you find your answer (direct evaluation using ’calculator’ will receive no credits).

4. (20 pts) Find the smallest N so that |∑_{i=0}^{N} \frac{3^{i}}{i!} − e^{3}| < 10^{−5}. Let your code print the

answer N and |∑_{i=0}^{N} \frac{3^{i}}{i!} − e^{3}| on screen, and also write them down on the answer sheet.

Extra credits for more efficient method(s).

Name your codes in the same format as 104000001 p03.m or 103000002 p04.c .