0% found this document useful (0 votes)
7 views3 pages

Errors 2

The document discusses various types of errors in computer arithmetic, including truncation errors, round-off errors, and errors due to original data inaccuracies. It explains how errors can propagate through calculations, especially in operations involving similar values, leading to significant inaccuracies. Additionally, it emphasizes the importance of minimizing round-off errors through efficient computation techniques, such as nested multiplication, and highlights the need for sensitivity analysis in mathematical models.

Uploaded by

thamsanqadube008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Errors 2

The document discusses various types of errors in computer arithmetic, including truncation errors, round-off errors, and errors due to original data inaccuracies. It explains how errors can propagate through calculations, especially in operations involving similar values, leading to significant inaccuracies. Additionally, it emphasizes the importance of minimizing round-off errors through efficient computation techniques, such as nested multiplication, and highlights the need for sensitivity analysis in mathematical models.

Uploaded by

thamsanqadube008
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Arithmetic and errors

MTHBD/CMPBD 423
• Truncation Error
x2 x3
ex ≈ 1 + x + +
2 6
• Round-Off Error
When the true value of a number is not stored exactly by a computers representation, (either by
conversion to a nonterminating fraction, in the computers base, or input beyond precision) the error
associated with this imperfection is called Round-Off Error.
• Error in Original Data
In mathematical models, you may have coefficients that are obtained by imperfect real world mea-
surements. Or perhaps the model does not perfectly reflect the real world. Nothing we can do about
this but is is worth doing a sensitivity analysis on the parameters.
• Propagated Errors:
Suppose a real number x is represented by the machine as x∗ where x∗ = x(1 + δ ) and δ (the initial
relative error) is small.
Suppose I want to calculate x2 . In the machine I’ll get (x∗ )2 = x2 (1 + δ )2 . Now I get an error

E = (x ) − x = x (1 + δ ) − 1 ≈ x2 (2δ ) which can be very big, especially if x is big. If I look
2 2 2 2


at relative error = xE2 , I still get a relative error of 2δ . Notice, the relative error doubled. This is an
example of an error being propagated.
• Computer Arithmetic
– machine numbers: Three parts: the sign, the fraction part called the mantissa or significand,
and the exponent called the characteristic.
±.d1 d2 d3 . . . d p ∗ Be
∗ B = the base that is used generally: 2, 16, 10
∗ di ’s digits or bits 0 < d1 < B and 0 ≤ di < B for i 6= 1.
∗ p = the precision the number of significand bits.
∗ e = the characteristic maybe 7 bits long.
– MATLAB’s max and min values (default is double precision):
∗ The maximum positive number is ≈ 10308 .
∗ The smallest positive number is ≈ 10−100 .
∗ The machine eps is ≈ 10−16 . Machine eps is the largest number such that: 1 + machine
eps = 1.
– errors in conversion (round-off error)
1
In base 2, 10 is the repeating decimal .11002 . It will never be stored exactly in a base 2
machine.
100,000
1
In MATLAB: |10, 000 − ∑ | ≈ 2 · 10−8
k=1 10
– relative and absolute error
If p∗ is the machine’s approximation to p:
∗ absolute error = |p − p∗ |
|p − p∗ |
∗ relative error = provide p 6= 0.
|p|

1
– Arithmetic Accuracy (loss of significance)
Suppose we are using base 10, five digit (chopping) arithmetic.

Actual computer
variable Value Value
x 1/3 0.33333 x 100
y 5/7 0.71428 x 100
u 0.714251 0.71425 x 100
v 98765.9 0.98765 x 105
w 0.111111 x 10−4 0.111111 x 10−4

computer cumputer Actual Absolute Relative


operation Result Value Error Error
x+y 0.10476 x 101 22/21 0.190 x 10−4 0.182 x 10−4
y−x 0.38095 x 100 8/21 0.238 x 10−5 0.625 x 10−5
x·y 0.23809 x 100 5/21 0.524 x 10−5 0.220 x 10−4
y÷ x 0.21428 x 101 15/7 0.571 x 10−4 0.267 x 10−4

y−u 0.30000 x 10−4 0.34714 x 10−4 0.471 x 10−5 0.136


(y − u) ÷ w 0.27000 x 101 0.31243 x 101 0.424 0.136
(y − u) · v 0.29629 x 101 0.34825 x 101 0.465 0.136
u+v 0.98765 x 105 0.98766 x 105 0.161 x 101 0.163 x 10−4
lesson: Subtracting similar values creates a large relative error. This is called a loss of signifi-
cance. Also, adding two numbers of disparate size causes large absolute error. For example in
MATLAB: 1, 000, 000 + 10−11 = 1, 000, 000.
– Avoiding loss of significance due to subtracting similar numbers in the quadratic formula.
Recall the roots of ax2 + bx + c can be found by
√ √
−b + b2 − 4ac −b − b2 − 4ac
x1 = and x2 = (1)
2a 2a

Suppose b2 − 4ac > 0, b > 0 and b ≈ b2 − 4ac. There is thus a good chance of x1 containing
a large error, especially if a is relatively small. We resolve this by changing the form of x1 by
rationalizing the numerator
√ √ !
−b + b2 − 4ac −b − b2 − 4ac −2c
x1 = √ = √ (2)
2a −b − b2 − 4ac b + b2 − 4ac
With the above form for x1 the subtraction of nearly equal numbers is eliminated. Therefore,
it would be wise to calculate x1 by equation (2) and x2 by equation (1). A similar revision
is needed if b < 0 in which case, x2 from equation (1) is at risk of losing precision due to
subtracting similar numbers.

2
– Avoiding round off error with nested multiplication
Even in the absence of subtracting similar numbers, there will be round-off error and the best
way to minimize this is to reduce the number of computer operations. A good example of this
is nested multiplication.
Consider the function f (x) = x3 − 6x2 + 3x − 0.149 evaluated at x = 4.71. We will assume
three digit base 10 arithmetic for the machine computations.
∗ traditional evaluation: 5 multiplies and 3 adds/subtracts.
The relative error with either chopping or rounding is ≈ 0.04
∗ nested multiplication: 2 multiplies and 3 adds/subtracts.

f (x) = ((x − 6)x + 3)x − 0.149 (3)


The relative error with chopping is ≈ 0.0093
The relative error with rounding is ≈ 0.0025

• Error analysis of algorithms generally assumes perfect precision, ie. no round-off error. However,
it is there and is worth keeping it in mind. Especially if you are doing many sequential calculations
where the output from one is input into another. In this way, errors can be propagated and your final
answer can be garbage.

You might also like