Numerical Methods - Lecture Notes_part_1-1
Numerical Methods - Lecture Notes_part_1-1
Module BIWO-04
Numerical Methods
1
Numerical analysis
▪ discipline of mathematics
▪ design, development and study of algorithms that use numerical approximation for
solution to the problems of continuous mathematics, for which :
▪ integration
2
Contents: 1. Introduction Seite 4
6. Approximation Seite 53
3
1. Introduction
▪ 2 types of algorithm:
- direct methods compute the exact solution to a problem in a finite
number of steps (unlimited computer precision assumed)
(e. g. Gaussian elimination method)
- iterative methods form successive approximations that converge to the
exact solution only in the limit
(e. g. Newton's approximation method)
▪ criteria:
runtime: - number of calculation steps to solve the problem
stability: - an algorithm is a) stable
b) weakly stable
c) unstable
a) decrease
b) is about the same size
c) increase
in the next calculation steps
- associated with
4
▪ condition of the problem:
- dependency of the solution of the problem on a variation or error of the input
data
problem algorithm
- absolute error:
- relative error:
5
2. Programming with Fortran
▪ FORmula TRANSlator
general-purpose programming language that is especially suited to
numeric computation and scientific computing
▪ source code machine code
Compiler
.f90 .exe
- program header
- declaration part
- procedure body
- end of program
! keine
Unterscheidung
6
- symbol set: 26 upper case letters A–Z
26 lower case letters a–z ! no
differentiation
10 numerals 0–9
1 underline _
5 arithmetic symbols + - * / **
17 further symbols ( ) . = , ‘ $ : ! “ % & ; < > ? space
implicit none
data arrays
explicit declaration
8
▪ procedure body:
- value assignments: variable name = term
- arithmetic operators:
hierarchy
pyramid of the
operators () brackets
** exponential
* / multiplication, division
+ - addition, subtraction
9
- logical operators:
comparison: == or .eq.
/= “ .ne.
> “ .gt.
>= “ .ge.
< “ .lt.
<= “ .le.
example result
3<4 or 3.lt.4 .true.
3<=4 or 3.le.4 .true.
3==4 or 3.eq.4 .false.
hierarchy
pyramid of the
== /= < <= > >=
operators
10
- functions:
exp(x) exponential function
log(x) natural logarithm
log10(x) common logarithm
sqrt(x) square root
abs(x) absolute value
sin(x) sine radian
asin(x) arc sine
int(x) real value into integer by truncation
nint(x) real value into integer by rounding
real(i) integer value into real
min(a,b) minimum value of a and b
max(a,b) maximum value of an and b
11
- conditional statements:
12
- loops:
do
program statement 1
program statement
…
if (logical condition) exit
program statement m
program statement n
…
end do
13
- input and output:
location format
close (unit)
14
3. Linear algebra
3.1 Vector calculus
▪ dot product
- properties
- application
a) perpendicular vectors
b) length/norm of a vector
c) angle between two vectors
d) distance of two points given by
their position vector
15
▪ cross product (in )
- properties
- application
16
▪ linear dependency of vectors
- properties
- application
volume of the parallelepiped spanned by three vectors
17
3.2 Matrix calculus
▪ notation columns
rows
▪ quadratic matrix
main diagonal
secondary diagonal
▪ transposed matrix
▪ symmetric matrix
18
▪ matrix of the same dimension
- properties
19
▪ multiplication with a scalar
▪ multiplication of matrices
- FALK‘s scheme
20
▪ properties
▪ diagonal matrix
all elements outside the main diagonal = 0
= quadratic
= symmetric
21
- properties all elements of the th row of are
multiplied with
if for
▪ permutation matrix
- properties
permutation of row and of
- example
23
▪ tridiagonal matrix
band width:
24
▪ triangular matrix
upper lower
25
▪ determinant
- a special number associated with any square matrix
26
Laplace's formula
3.
4.
5.
▪ inverse of a matrix
is invertible, if
for
2
▪ example ( ):
▪ rank of a matrix
- a special number associated with any matrix
- maximal number of linearly independent columns (rows)
- column rank = row rank
- properties
▪ system
matrix notation
homogeneous
inhomogeneous
30
▪ solvability : a) no solution
b) one solution
c) infinitely many solutions
homogeneous inhomogeneous
with
ill-conditioned
31
Algorithms
Gaussian elimination
to triangular form:
e.g.
32
▪ procedure : row 2 to :
row 3 to : analogous,
▪ properties
▪ example
33
Cramer's rule
▪ precondition
▪ properties
34
Cholesky decomposition
▪ precondition
positive definite :
▪ algorithm :
with and
35
▪ example ( ):
- equating coefficients:
for
for
for
- solve :
- solve :
36
▪ properties
- numerically stable
- by extracting the square root large main diagonal elements become larger,
i.e. a reduction of the loss of decimal places
good for ill-conditioned problems
- less costly than Gaussian elimination
- necessary for positive definiteness : easy to negative it
- a band structure of is transferred to
- minor effort for further
or
geometrical interpretation:
ellipse:
37
normal vector:
principal axis
formal interpretation:
Transformation:
38
Algorithms
nontrivial solution, if
polynomial of degree
roots
power iteration:
- Termination condition:
40
- iteration:
- standardization:
- in general:
41
▪ properties:
= real-valued, symmetric
eigenvalues are real-valued
eigenvectors corresponding to different eigenvalues are orthogonal to each other
all eigenvalues are real-valued and a.) greater or b.) lower than zero
Rayleigh quotient:
42
3.5 Generalized eigenvalue problem
or
▪ statics/dynamics:
similarity
transformation
(eigenvalues
remain unchanged) 43
4. Systems of nonlinear equations
▪ iterative algorithms:
improve approximate solution successively until a required accuracy is reached
44
4.2 Secant method
termination: or
45
4.4 Newton's method
46
5. Numerical integration
▪ one-dimensional problem
5.1 Quadrature rules based on interpolating functions
rectangle method
mit
▪ properties:
- convergence
- error decreases proportionally to
47
trapezoidal rule
mit
▪ properties:
- convergence
- error decreases proportionally to
Simpson's rule
with
▪ properties:
- convergence
- even
- error decreases proportionally to
48
Newton-Cotes-Formeln
Gaussian quadrature
for
tabulated
49
▪ multidimensional poblems
5.2 Monte Carlo integration (simulation)
▪ example:
50
„random numbers“
- random number generators generate uniformly distributed realizations within the interval [0, 1]
necessary: transformation into the required intervals [a1, b1], [a2, b2], …
51
▪ example:
52
6. Approximation
function approximation
▪ Taylor series
- one-dimensional problem:
times differentiable
▪ example:
53
n=1 n=3 n=5 n=15 n=oo
0
-8 -6 -4 -2 0 2 4 6 8
-1
-2
-3
-4
discrete data
linear interpolation
- one of the simplest methods
- two data points and are interpolated by a linear function
polynomial interpolation
- for mutually distinct data points with
one specific interpolating polynomial of maximum degree exists
(fundamental theorem of algebra)
with
and
▪ Newton polynomial:
mit
► continuity ( equations):
57
► 2 boundary conditions (variable):
- periodic spline ( ):
- fixed boundaries:
- not-a-knot:
1.
2.
3.
with:
58
▪ properties: - tridiagonal
- symmetric
- diagonally dominant
- positive definite
- only positive elements
- well-conditioned
- invertible
4.
5.
59
▪ algorithm (periodic spline):
it holds:
1.
2.
with:
3.
60
4.
5.
▪ multidimensional poblems:
61
7. Computer graphics
7.1 Coordinate transformation
▪ geometric transformations of three-dimensional (spatial) objects:
- translation vector addition
- rotation
- scaling matrix multiplication
- shear
62
- avoiding of rounding errors
- reducing computational effort
combining successive geometric transformations to one single transformation matrix
63
translation:
scaling:
shear:
64
rotation about Z-axis:
7.2 Projection
orthogonal projection:
65
perspective projection: + standardization (division
by the fourth component) !!
+ standardization (division
by the fourth component) !!
66