Professional Documents
Culture Documents
Numerical Methods
Andreas Grtler
mathematical equations
This does not mean, that they are solved easily!
For any application, you need numbers
Numerical Methods!
Needed for most basic things:
exp(3),sqrt(7),sin(42), log(5) ,
Often, modeling and numerical calculations can help
in design, construction, safety
Note: many everydays problems are so complicated
that they cannot be solved yet
Efficiency is crucial
Errors
Numerical errors
Roundoff error: finite precision
numerical calculations are almost always
approximations
modeling error
Truncation errors
Truncation errors are problem specific
Often, every step involves an approximation,
e.g. a finite Taylor series
The truncation errors accumulate
Often, truncation errors can be calculated
Roundoff errors
Precision of representation of numbers is finite
- errors accumulate
a real number x can be represented as
fl(x) = x(1+) :
floating point computer representation
|fl(x)-x| = x
|fl(x)-x|/x =
0.6
0.8
0.4
0.2
0
0
10
20
30
Iterations
40
50
Computer
representation of
numbers
standard!
less precision, half memory
Complex:
w=2+3i; v=complex(x,y)
special values:
Normalized:
N=1.f 2p
Denormalized:
N=0.f 2p
bit (double)
use
63
sign
62 52
Exponent p
51 0
Significant f
SI
a.u.
charge e
1.62E-19 C
mass me
9.1E-31 kg
energy Eh
4.36E-18 J
distance a0
5.3E-11 m
velocity c
2.99E8 m/s
1/137
0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1-1
FALSE!!!
-1E-16
(if f differentiable)
f ( x) xf ' ( x) x
f ( x)
f ( x) x
(0.00505)
Condition numbers:
f1(x)= 99-70 x
f1(x)= 1/(99+70 x)
f1(1.4) = 1
f2(1.4) 0.0051
2 20000
2 0.5
what happened?
f1: 99-70*2
f2: 1/(99+70*2)
= |-x/(x-a)|
= |x/(x+a)|
= |xa/(ax)| =1
= |xx-2/(x-1)| =1 well-conditioned
numerical disasters
Patriot system hit by SCUD missile
position predicted from time and velocity
the system up-time in 1/10 of a second
was converted to seconds using 24bit
precision (by multiplying with 1/10)
1/10 has non-terminating binary expansion
after 100h, the error accumulated to 0.34s
the SCUD travels 1600 m/s so it travels
>500m in this time
Ariane 5
a 64bit FP number containing the horizontal
velocity was converted to 16bit signed
integer
range overflow followed
from
http://ta.twi.tudelft.nl/nw/users/vuik/wi211/disasters.html
f(x)=0
task: find the zero-crossing (root) of f(x)
no roots
extrema
many roots
singularities
roots which are not FP numbers
roots close to 0 or at very large x
There are different methods with
advantages and disadvantages
10
5
0
0
10
5
0
-2
100
0
-100
-1
1
0
-1
-1
f(x)
a
a1
b
p1
b1
a2 p2 b2
a3 p3 b3
4
2
0
-2
f(x)
-0.5
0.5
50
0
-50
-100
-1
apb
-1
100
| f ( p ) |
| a b |
| a b| / p
| pn pn 1 | / pn
-2
problematic for
singularities, small f(x)
large a,b
p0
p0, small f(x)
convergence
Proof:
(an bn )
(bn an ) (b a )
pn
pn p
n
2
2
2
convergence is linear
order of convergence
n n 0
Let { p }
converge to p with
| pn 1 p |
lim
n | p p |
n
then pn converges with order
=1 : linear convergence
=2 : quadratic convergence
pn pn
a
a1
b
p1
b1
a2 p2 b2
initialize a,b
p=(a+b)/2
while abs(b-a)> do
f(p)*f(a)<0 ?
-> b=p
f(p)*f(b)<0 ?
-> a=p
repeat
a3 p3 b3
Exercise
(x>0)
solve x3 = ln(1+x)
a1 p1
b1
(x>0)
using bisection
function ret=f(x)
% function of which root should be found
ret=x^3-log(1+x);
end
a2 p2 b2
Bisection in words:
1. choose an interval (a,b)
around the root
2. calculate the center point
p=(b+a)/2
3. if p approximates the root
well enough, STOP
4. if the root is in (a,p)
set b=p
5. if the root is in (p,b)
6.
set a=p
7. goto step 2
a3 p3 b3
% bisection.m
a=0.1; b=2;
p=(a+b)/2;
epsilon=1E-10;
n=1;
while abs(b-a)>epsilon
if (f(p)*f(a)<0)
b=p;
end
if (f(p)*f(b)<0)
a=p;
end
p=(a+b)/2;
n=n+1;
end
fprintf ('Root: %f, Steps: %d.',p,n);