CSE213 - Numerical Analysis Sheet 1 - Error Analysis To Be Submitted On The 25 of February
CSE213 - Numerical Analysis Sheet 1 - Error Analysis To Be Submitted On The 25 of February
1. Absolute and Relative Errors: If x is the exact value and x* is the approximate
value, calculate the absolute and relative errors when
a. x = 10.147, x* = 10.159
b. x = 0.0047, x* = 0.0045
c. x = 671000, x* = 669000
sin(x) = ∑ −1 ( )!
Page 1
4. Verify that the chopping error resulting from calculating (1.0⁄6.0) to 2 significant
digits will cause that (1.0⁄6.0) ∗ 6.0 ≠ 1.0. Verify that when ( 1.0⁄6.0 ) is
approximated to 5 decimal digits, the result of (1.0⁄6.0) ∗ 6.0 will be 0.9996.
5. The critical part of floating-point operations is the potential loss of correct digits in
the significand. Consider a computer model that uses 4 digits for the significand, 1 digit
for the exponent plus an optional sign for both the significand and the exponent, any
real number 'a' may be written as a normalised decimal number a×10n, where the
number 'a' is in the range [0.1, 1) and is called the significand, while the integer n is
called the exponent.
Convert the following numbers to normal form and perform the required operation:
a = 42.34 and b = 0.0033, calculate a+b
a = 10.34 and b =-10.27, calculate a+b
a = 10/7 and b =-1.42, calculate a+b
a = 23.57 and b =-6.759, calculate a*b and a/b
7. The following Python program shows the effect of the propagation of an initial
representation error which results in final (large!) error. Run the program, print its
results once for k in range(10) and in range(30). Comment on the obtained results.
a=[]
for n in range ( 1 ,11) :
x=1/n
for k in range(30) :
x=(n+1)*x-1
a . append ( x )
print(a)
Page 2
8. Errors in Computer Arithmetic
In order to reduce the chance of large errors occurring in calculations, here are some
tips that you should consider:
Assuming the Discriminant: b2 – 4ac > 0, then depending on the sign of b, a “bad
subtraction” may be encountered when we try to find the smaller one of the two roots.
This implies that it is safe, from the “loss of significance” point of view, to compute the
root having the larger absolute value first and then obtain the other root by using the
relation (between the roots and the coefficients) x1 x2= c/a.
a) Apply this technique to solve the equation x2 + 62.10 x + 1 = 0 whose roots are
Approximately : x1 = -0.01610723 and x2= -62.08390. Check the relative errors
in the obtained roots (using four-digit rounding arithmetic) in case of finding both
roots using the formulas and the case of avoiding "bad subtraction".
b) Apply the idea of rationalizing the numerator of the quadratic formula to obtain a
more accurate four-digit rounding approximation for x1:
Page 3
iii. In consecutive multiplication/division processes, make the intermediate result as
close to one as possible. According to this rule, when computing xy/z, we program the
formula as
(xy)/z when x and y in the multiplication are very different in magnitude,
x(y/z) when y and z in the division are close in magnitude, and
(x/z) y when x and z in the division are close in magnitude.
For instance, when computing y n/ en x with x >1 and y >1, we would program it
as (y/ex)n rather than as y n/ en x , so that overflow/underflow can be avoided. Verify this
using Excel/ Python/ Matlab for the case:
x = 36; y = 1e16; for n = {-20, -19, 19, 20}.
Page 4