Professional Documents
Culture Documents
Representing Numbers
Accuracy and Precision
• Accuracy – how closely a
increasing accuracy measured value agrees with
the truth
• Precision – how closely
measured values agree with
increasing precision
each other
𝑡𝑟𝑢𝑒 −𝑐𝑎𝑙𝑐𝑢𝑙𝑎𝑡𝑒𝑑
• Relative error
𝐸𝑅= | 𝑡𝑟𝑢𝑒 |
• true = 1.5 cm, calculated = 1 cm
• absolute = 0.5 cm
• relative = 0.333
0
0
𝑓 ( 2.3 )=0
1 2 3 4 5
|
𝐸𝑅=
max {∨𝑓 𝑐 ( 𝑥)∨,∨𝑓 ( 𝑥 )∨}|
-1
Celsius
2) Relative measurements Kelvin
true C K
calculated C K
= 283 −284
𝐸 = 10− 11
𝑅 |
10 | 𝐸 𝑅
283 | |
𝐸
𝑅 =0.1=10 % 𝐸
𝑅 =0.0035=.35 %
Sources of error
• Inaccuracy often results from a bias in the algorithm
• Euler’s method for explicit integration [discussed later] returns
biased results based on the curvature of the solution to the
differential equation
• Creating more accurate algorithms is a cornerstone of numerical
methods
+ + x x
Floating Point, base 10
23
. 602× 10
exponent
mantissa base
• spend
a few bits on the mantissa and a few on the exponent
• effectively represent very large and very small numbers
• is the base
• is a sign bit
• is the mantissa, where
• is the exponent
2) Add:
3) Normalize:
• What is the actual solution and the corresponding relative
error?
1)
2)
where is the correct result, the relative error is
Loss of Precision
• Each
operation maintains the appropriate precision
• However, we end up with far less precision than we expect
• The result has one digit of precision
• The correct value of requires two digits of precision
• We expect , we only need , but we get
• This is known colloquially as catastrophic cancellation
• How could we have avoided loss of precision in this case?
for some positive integers and , then at most and at least significant
digits are lost in the subtraction .