Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Error continued.....

Department of Mathematics
IIT Guwahati

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

Cancellation error: how to avoid it in practice?

Using this formula, computing the expression in 5 digit decimal arithmetic


yields 1.5811 × 10−3 .(Excersise) ( Exact value is 1.58113487 × 10−3 )

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

Underflow and Overflow: Consider a floating point system with 4


decimal digits and 2 exponent digits ( i.e. −99 ≤ e ≤ 99,). Compute
p
c = (a2 + b2 ) for a = 1060 and b = 1.

f l(a) = 1.000 × 1060 , f l(b) = 1.000 × 100 .


f l(a) × f l(a) = 1.000 × 10120 which cannot be represented in this
floating system as exponent is three digit number.

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

Underflow and Overflow: Consider a floating point system with 4


decimal digits and 2 exponent digits ( i.e. −99 ≤ e ≤ 99,). Compute
p
c = (a2 + b2 ) for a = 1060 and b = 1.

f l(a) = 1.000 × 1060 , f l(b) = 1.000 × 100 .


f l(a) × f l(a) = 1.000 × 10120 which cannot be represented in this
floating system as exponent is three digit number.
How to avoid it? Rewrite the expression as
p
c = s (a/s)2 + (b/s)2 for any s 6= 0.

Thus if we use s = a = 1060 there will be an underflow in (b/s)2 ,


f l((b/s)2 ) = 1.000 × 10−120 , this will be set as zero. Finally we get the
correct answer up to the precision of floating point system.

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!
Accumulation of roundoff error: x, y and z are machine numbers in 32
bit system.

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!
Accumulation of roundoff error: x, y and z are machine numbers in 32
bit system.

Theorem
(On the relative roundoff error in adding) Let x0 , x1 , · · · , xn be positive
machine numbers in a computer whose unit roundoff error is η. Then the
relative roundoff error in computing
n
X
xi
i=0

in the usual way is at most (1 + η)n − 1 ≈ nη.


SUDARSHAN K. K. MA311 (2018)
Rude behavior of roundoff error!!
10 -8
6

4
roundoff error

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t

Figure: Error in sampling exp(−t)(sin(2πt) + 2) in single precision.

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!
Root of quadratic polynomial: Example. Fining roots of
x2 + 62.10x + 1 = 0 in 4 digits decimal floating point system. Exact
roots are found to be

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

[Compare with ax2 + bx + c = 0] The effect is due to the fact that



b2  4ac and b2 − 4ac ≈ |b|. To reduce the error we use the formula
x1 x2 = 1 We compute x2 as it is and

x1 = 1/x2 ; f l(x1 ) = 1.000/(−62.0) = −0.01610

| − 0.01610723 + 0.01610|
≈ 4.4 × 10−4 .
| − 0.01610723|

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

Nested arithmetic:
pm (x) = c0 +c1 x+· · ·+cn xn → pn (x) = (. . . ((cn xn +cn−1 )x+cn−2 )x.....)x+c0 .

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

Nested arithmetic:
pm (x) = c0 +c1 x+· · ·+cn xn → pn (x) = (. . . ((cn xn +cn−1 )x+cn−2 )x.....)x+c0 .

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

SUDARSHAN K. K. MA311 (2018)


Rude behavior of roundoff error!!

You save number of operations! → the number of operations comes


down to O(n) from O(n2 ) when we calculate the value of a nth order
polynomial.;

SUDARSHAN K. K. MA311 (2018)


Catastrophe due to roundoff error!! :(

• Patriot missile failure in Dhahran, Saudi Arabia, on February 25,


1991, which resulted in 28 deaths.pause
• Intel Pentium flaw (1994):
http://en.wikipedia.org/wiki/Pentium FDIV bug
A = 4195835.0, B = 3145727.0; A − (A/B) ∗ B =? (five digit
arithmetic)

SUDARSHAN K. K. MA311 (2018)


Catastrophe due to roundoff error!! :(

• Patriot missile failure in Dhahran, Saudi Arabia, on February 25,


1991, which resulted in 28 deaths.pause
• Intel Pentium flaw (1994):
http://en.wikipedia.org/wiki/Pentium FDIV bug
A = 4195835.0, B = 3145727.0; A − (A/B) ∗ B =? (five digit
arithmetic)
• The Explosion of the Ariane 5, June 4- 1996.

SUDARSHAN K. K. MA311 (2018)


Numerical instability

To compute ( 13 )15 .

SUDARSHAN K. K. MA311 (2018)


Numerical instability

To compute ( 13 )15 .
1 13 4
x0 = 1, x1 = ,··· xn = xn−1 − xn−2 .
3 3 3
Thus x15 = ( 31 )15 can be computed successively using the sequence
above.

SUDARSHAN K. K. MA311 (2018)


Numerical instability

To compute ( 13 )15 .
1 13 4
x0 = 1, x1 = ,··· xn = xn−1 − xn−2 .
3 3 3
Thus x15 = ( 31 )15 can be computed successively using the sequence
above.
If there is no roundoff error in the computer we will get the exact value of
x15 .

SUDARSHAN K. K. MA311 (2018)


Numerical instability

To compute ( 13 )15 .
1 13 4
x0 = 1, x1 = ,··· xn = xn−1 − xn−2 .
3 3 3
Thus x15 = ( 31 )15 can be computed successively using the sequence
above.
If there is no roundoff error in the computer we will get the exact value of
x15 .
What happens if there is roundoff error?

SUDARSHAN K. K. MA311 (2018)


Numerical instability

SUDARSHAN K. K. MA311 (2018)


Numerical instability

Speaking informally, we say that a numerical process is unstable if small


errors made at one stage of the process are magnified in subsequent
stages and seriously degrade the accuracy of the overall calculation.
SUDARSHAN K. K. MA311 (2018)

You might also like