0 Preliminaries
0 Preliminaries
• Introduction
• Analysis vs. numerical analysis
• Computers and numerical analysis
• A Typical Example
• Implementing Bisection
• Computer Arithmetic and Errors
• Interval arithmetic
• Measuring the efficiency of numerical
procedures
– Not good
– 1036.52 +- 0.010
• accurate to 5 significant digits
• adequate precision
– 0.005 +- 0.010
• bad precision
• Relative error
absolute error
| true value |
– More independent of the scale of the value
• Sign
• Fraction part (Mantissa)
– Normalized mantissa: 0.b1b2….bk x 2^p, b1 =\0=1. (so no
need to store it.)
– A notable exception is zero: all 0 in exponent and mantissa
• Exponent part
Numerical Method, Chap 0 2024 11 Jung Hong Chuang, CS Dept., NYCU
Floating-point arithmetic
IEEE standard – Extended
q 2m • Length: 80
• 3 levels of precision Sign: 1, Mantissa: 64
Exponent: 15,
– Single precision Range: 10+-4931
• Length: 32 bits – Biased exponent
Sign: 1,
• Allows negative
Mantissa q: 23(+1)
exponent w/o sign bit
Integer exponent |m|: 8, by adding a bias value
sign of m: 1 bit to actual exponent
largest m: 2 1 127
7
value to make all
Range: 10+-38 exponents range from
127
2 1038 0 to max
– Double
• Length: 64 • For single precision,
bias value is 127,
Sign: 1, Mantissa: 52
max=2^8=256, so -
Exponent: 11, 127 stored as 0, 128
Range: 10+-308 as 255.
Numerical Method, Chap 0 2024 12 Jung Hong Chuang, CS Dept., NYCU
Floating-point arithmetic
IEEE standard
Normalized mantissa:
– Forward error
Efwd=ycalc-yexact
– Backward error
Let xcalc be the x value that gives ycalc with no
computation error
Ebackw=xcalc-x
Examples :
[0.5, 0.8] [-1.2, 0.1] [-0.7, 0.9]
[0.5, 0.8] [-1.2, 0.1] [0.4, 2.0]
[0.5, 0.8] [-1.2, 0.1] [-0.96, 0.08]
Numerical Method, Chap 0 2024 26 Jung Hong Chuang, CS Dept., NYCU
Measuring efficiency/error
• How to measure efficiency?
– Based on operation count
– O(n): order of n, O(n^2): order of n^2
• How to measure error?
– Based on size of a parameter, say h. For Example,
• Solve dy/dx=f(x,y) with a value given for y at some value
for x
• Some methods add a weighted sum of estimated values
for the derivative function at evenly spaced x-values that
differ by h
• For one method the Error=(M/6)*h^3, where M depends
on a value for the 3rd derivative of f(x, y)
– O(h^3)