Professional Documents
Culture Documents
T01 Floating Point
T01 Floating Point
Numerical Methods
2019-2020
Discrete World
in space or in time
must be represented
in a discrete world
2019-2020
Discrete World
2019-2020
Floating Point Numbers
37.21829, 0.002271828
Numerical Methods
2019-2020
Floating Point Numbers
37.21829 0.3721829 10 2
Numerical Methods
2
0.002271828 0.2271828 10
2019-2020
Floating Point Numbers
x 0.d1 d 2 d 3 10 n
Numerical Methods
d1 0
2019-2020
Floating Point Numbers
1
x r 10 n r 1
10
Numerical Methods
2019-2020
Floating Point Numbers
2
• q will be then a bit sequence bi (0 or 1) with
the additional condition:
b1 1
2019-2020
Floating Point Numbers
2019-2020
Floating Point Numbers
• The finite set of numbers that can be
represented in a computer will be called the
set of machine numbers
x 0.1b2 b3 bn 2 2 m
Numerical Methods
0.12 2 m
2019-2020
Floating Point Numbers
Radix Point
16 bites 48 bites
Numerical Methods
2019-2020
Floating Point Numbers
ଵସ
Numerical Methods
2019-2020
Computer Errors
d 49d 50 K
2019-2020
Computer Errors
x' 0.1d 2 d 3 d 48 2 2 m
proceed as follows:
a x x'
• If we are using the rounding of numbers,
Numerical Methods
then:
1
a x x' x' ' x' 2 49 m
2
• The absolute error will depend on the
magnitude of the number (through m)
2019-2020
Relative Error
2019-2020
Computer Errors
• If during the computing operations we get a
number of the form:
q2 m
2019-2020
Arithmetic Operations
x y x' y ' a ( x) a ( y )
Numerical Methods
a ( x y ) a ( x) a ( y )
2019-2020
Matlab/Octave
2019-2020
Matlab/Octave
• Octave+GNUPlot (QtOctave) is a free
distribution software, with a similar functionality
to MatLab
Numerical Methods
2019-2020
Matlab/Octave
• In this soft we will find a great number of
integrated functionality. We get a programming
and many graphics facilities.
Numerical Methods
2019-2020
Matlab/Octave
2019-2020
Matlab/Octave
2019-2020
Matlab/Octave
2019-2020
Floating Point Operations
• The lower an
bigger number
that your
computer can
Numerical Methods
2019-2020
Floating Point Operations
• By Default, Matlab/Octave will work with a
precision of 16 decimal digits, but also by
default, will show you in the screen the values
in single precision (7 digits)
Numerical Methods
2019-2020
Floating Point Operations
2019-2020
Floating Point Operations
1 1 1 0 0 1 1 0
4 5 6 7 8 9 10 L
10 2 2 2 2 2 2 2
x fl ( x) 1
Numerical Methods
x 2
• Where fl(x) is the floating point representation.
The constant ε is called the machine epsilon.
2019-2020
Floating Point Operations
• This constant ε is the minimum distance
between two floating point numbers. It is also
the smallest relative error. This values is
predefined in eps and takes the value ε=2^(-52)
Numerical Methods
2019-2020
Floating Point Operations
2019-2020
Floating Point Operations
another example:
2019-2020
Loss of Significance
• The limited precision implies that we have to
pay special attention if we want to make good
programs.
• A common error appears when subtracting very
similar numbers. The relative error can be really
Numerical Methods
2019-2020
Loss of Significance
a ( x) a ( y )
r
x y
Numerical Methods
2019-2020
Loss of Significance
sin( x) 0.6661729492 10 1
x sin( x) 0.0004937175 10 1
0.4937175000 10 4
• We have lost three significant digits, i.e., a
relative error of 103
2019-2020
Loss of Significance
2
x 1 1 x2
f ( x) x 1 1
2
x2 1 1 x2 1 1
2019-2020
Loss of Significance
2019-2020
Loss of Significance
f1 ( x) x x 1 x i f 2 ( x)
x
x 1 x
Numerical Methods
2019-2020
Loss of Significance
2019-2020
Loss of Significance
2019-2020
Loss of Significance
• Evaluating these two expressions alternatively
we obtain
Numerical Methods
2019-2020
Loss of Significance
y ( x) x sin( x)
Numerical Methods
2019-2020
Transcendental Functions
ln(2)
Numerical Methods
2019-2020
Transcendental Functions
• We can use a polynomial to approximate this
kind of functions, thanks to:
• Weierstrass Approximation Theorem: If f is
defined and it si continuous within the interval
[a,b] and given any ε >0, There is some
Numerical Methods
f ( x) P( x)
for any x a, b
2019-2020
Taylor’s Polynomial
n
1
f ( x)
k 0 k!
f (k )
( c )( x c ) k E n ( x ),
where
1
E n ( x) f ( n 1) ( )( x c) n 1 .
(n 1)!
2019-2020
Taylor’s Polynomial
1 1
ln( x) ( x 1) ( x 1) ( x 1) 3
2
2 3
Numerical Methods
n 1 1
(1) ( x 1) n E n ( x)
n
2019-2020
Taylor’s Polynomial
1 ( n 1) 1
E n ( 2) n 1
(2 1) 10 8
n 1 n 1
Numerical Methods
2019-2020
Taylor’s Polynomial
• The Taylor Polynomial is just a local
approximation to a function
Numerical Methods
2019-2020
Taylor’s Polynomial
2019-2020
Error Propagation
• We can compute recursively the value of the
Bessel functions in order to see how the
propagation of errors can be catastrophic.
• The value of the Bessel functions Jn(x) when
x=1. Can be obtained with the recursive
Numerical Methods
relation:
1
J n 1 ( x) 2nx J n ( x) J n 1 ( x)
where
J 0 (1) 0.7651976865
J1 (1) 0.4400505857
2019-2020
Error Propagation
2019-2020
Error Propagation
2019-2020
Error Propagation
2019-2020