Errors 2
Errors 2
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
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.
• 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.