Zusammenfassung Numerische Mathematik
Patrik Rohner :: <rohnerpa@student.ethz.ch> :: FS’09
1 Grundlagen der Numerik
1.1 Gleitpunktarithmetik
Gleitpunktzahl: x ˆ = σM B
Eσ: Vorzeichen B: Basis M: Mantisse E: Exponent
F¨ ur die Mantisse M gilt:
M = ∑
lj=1m
−jB
−j0 ≤ m
−j≤ B − 1 : Ziffern der Mantisse
l : Mantissenl¨ ange (fest)
m
−1≠ 0 f¨ ur x ˆ ≠ 0 : Normierung
F¨ ur den Exponenten E gilt:
E = τ ∑
kj=1e
jB
k−jτ : Vorzeichen
0 ≤ e
j≤ B − 1 : Ziffern des Exponenten k : definierter Exponentenbereich Definition: M (B, l, k) = Menge der Maschinenzahlen
/ M (2,5,3) ⇒ M
max=
3132
≈ 1 M
min=
12
E
max/min= ±7 ˆ
x
max= M
max⋅ B
Emax=
3132
⋅ 2
7x ˆ
min= M
min⋅ B
Emin=
12
⋅ 2
−7/ M (B, l, k) ⇒ M
max=
Bl−1
Bl
M
min=
1B
E
max/min= ±B
k− 1 ˆ
x
max=
Bl−1
Bl
⋅ B
Bk−1ˆ x
min=
1B
⋅ B
−(Bk−1)Definition Maschinengenauigkeit: eps ist die kleinste Zahl, die zu 1 addiert noch eine Ver¨ anderung bewirkt.
∣ x − x ˆ
x ∣ ≤ B
E−L2B
E−1=
B
1−L2 =∶ eps
Pseudo-Arithmetik: (ˆ x + y) ⋅ ˆ z ˆ = z ˆ ⋅ (ˆ y + x) ˆ (ˆ x + y) ⋅ ˆ z ˆ ≠ ˆ x ⋅ ˆ z + ˆ y ⋅ z ˆ (ˆ x + y) + ˆ z ˆ ≠ x ˆ + (ˆ y + z) ⇒ ˆ von klein nach gross summieren
1.2 Fehlerfortpflanzung
Absoluter Fehler: ∆x = x ˆ − x
∆(x ± y) = (ˆ x ± y) − (x ˆ ± y) = ∆x ± ∆y
∆(x ∗ y) = ˆ xˆ y − xy ≅ x∆y + y∆x = xy(δx + δy)
∆(x/y) ≅ x/y(δx − δy) Relativer Fehler: δx =
∆xx
δ(x ± y) =
∆(x±y)x±y=
x±yx⋅
∆xx
±
x±yy⋅
∆yy
=
x±yxδx ±
x±yyδy δ(x ∗ y) =
∆(x∗y)xy≅ δx + δy
δ(x/y) =
∆(x/y)x/y≅ δx − δy
Ausl¨ oschung: ∣x ± y∣ ≪ {∣x∣,∣y∣} ⇒ ∣δ(x ± y)∣ ≫ ∣δx∣ + ∣δy∣
Faustregel: wenn δx = 10
−k, dann sind ≈ k Ziffern richtig.
⇒ besser (x
3− y
3)/(x
2+ xy + y
2) als x − y rechnen
⇒ besser (x
6− y
6)/(x
4+ x
2y
2+ y
4) als x
2− y
2rechnen
1.3 Kondition eines Problems
κ
H= Konditionszahl = Verst¨ arkungsfaktor des relativen Fehlers von x Konditionszahl κ
H: δH = ∣
xH′(x)
H(x)
∣ ∗ ∣δx∣ = κ
H∗ ∣δx∣
1.3.1 Kondition einer Matrix κ ( A ) = ∣∣ A ∣∣ ⋅ ∣∣ A
−1∣∣ :
A ⋅ x ˆ = ˆ b ⇒ ∣∣δx∣∣ ≤ κ(A) ⋅ ∣∣δb∣∣
A ˆ ⋅ x ˆ = ˆ b ⇒ ∣∣δx∣∣ ≤
1−κ(A)∣∣δA∣∣κ(A)(∣∣δA∣∣ + ∣∣δb∣∣)
Faustregel: Bei d Dezimalstellen und κ(A) ≅ 10
khat die L¨ osung im schlechtesten Fall noch d − k richtige Stellen.
in der 2-Norm: ∣∣A∣∣
2= √
µ
max(µ
max= max. EW von A
TA)
A orthogonal: A
T= A
−1∣∣A∣∣
2= 1
A symmetrisch: A
T= A ∣∣A∣∣
2= ∣λ
max∣ ∣∣A
−1∣∣
2=
∣λ1min∣
A regul¨ ar: ∣∣A
−1∣∣
2=
√ 1 µminκ(A) =
√ µ
max√ µ
minund falls A
T= A gilt κ(A) = ∣λ
max∣
∣λ
min∣ κ ≈ 1 gut konditioniertes Problem κ ≫ 1 schlecht konditioniertes Problem
>> k_A=cond(A)
2 Lineare Gleichungssysteme
2.1 LRP-Zerlegung
LRP-Zerlegung von A aus Ax = b . . . . i LRP-Zerlegung von A: LR = P A >> [L,R,P]=lu(A) ii Vorw¨ artseinsetzen: Lc = P b nach c >> c=L\(P*b) iii R¨ uckw¨ artseinsetzen: Rx = c nach x >> x=R\c Der Algorithmus braucht
23n
3+ 2n
2Operationen. O(n
3) 2.1.1 Pivotstrategien (gegen Ausl¨ oschung)
Diagonalstrategie: Diagonalelement = Pivot (schlecht)
Spaltenmaximumstrategie: Das betragsm¨ assig gr¨ osste Element wird gew¨ ahlt.
relative Spaltenmaximumstrategie: Das betragsm¨ assig gr¨ osste Element, relativ zum zweitgr¨ ossten Element der Zeile, wird gew¨ ahlt.
2.2 Iterative Methoden
Alle hier ben¨ otigen pro Iterationsschritt grob eine Matrix-Vektor- Multiplikation (O(n
2), wenn sparse: O(n)) und konvergieren linear (O(n)).
2.2.1 station¨ are Iterationsverfahren x
k+1= T ⋅ x
k+ c
Der absolute Fehler ver¨ andert sich mit e
k= T
k⋅ e
0, womit gilt:
Konvergenzbedingung: ∣∣T ∣∣ < 1 >> norm(T)
F¨ ur den Spektralradius ρ(T ) ∶= max ∣λ
i∣ gilt ρ(T ) ≤ ∣∣T ∣∣ und so alternative Konvergenzbed.: ρ(T ) < 1 >> max(abs(eig(T))) Absch¨ atzung (worst case) der Anzahl Iterationen f¨ ur bestimmte Fehler:
∣∣e∣∣
2= ∣∣T
ke
0∣∣
2∣∣e
k∣∣
2≤ ∣∣T ∣∣
k2∣∣e
0∣∣
2 ∣∣ek∣∣2
∣∣e0∣∣2
≤ ∣∣T ∣∣
k2k ≥
ln(rel.Fehler) ln∣∣T∣∣2Aufspaltung f¨ ur bestimmte Verfahren A = L + D + R
>> D=diag(diag(A)) >> L=tril(A)-D >> R=triu(A)-D Jacobi-Verfahren
T = −D
−1⋅ (L + R) c = D
−1b
Konsistenzbedingung: A regul¨ ar, d.h det(A) ≠ 0
hinreichende Konvergenzbedingung: A strikt diagonal dominant (max
∣.∣ in der Diagonalen)
notwendige Konvergenzbedingung (bei allen 3 Verfahren): ∣∣T ∣∣ < 1 Gauss-Seidel-Verfahren
T = −(D + L)
−1R c = (D + L)
−1b (D + L)x
k+1= −Rx
k+ b >> x (k+1)=(D+L)\(-Rx k+b)
Falls A strikt diagonal dominant oder A symmetrisch positiv definit ist, konvergiert das Verfahren, und zwar schneller als das Jacobi-Verfahren.
SOR-Verfahren (Successive Over-Relaxation) x
k+1= (D + ωL)
−1[−ωR + (1 − ω)D]
´¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¸¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¶
=T(ω)
x
k+ (D + ωL)
−1ωb
´¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¸¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¶
=c(ω)
ω = Relaxationsparameter ω
optimal=
21+√
1−[ρ(D−1(L+R))]2
ρ: Spektralradius
2.2.2 Methode der konjugierten Gradienten (CG)
Zu l¨ osendes Gleichungssystem: Ax + b = 0
Voraussetzungen: A symmetrisch und positiv definit.
F(u) ∶= 1/2u
TAu + u
Tb gradF =
⎛
⎜ ⎜
⎝
∂F
∂u1
...
∂F
∂un
⎞
⎟ ⎟
⎠
= Au + b = r(u) (Residuen) Idee: Anstelle Ax + b = 0 zu l¨ osen, wird das Minimum von F(u) gesucht.
Es gilt F (x) = min
u∈RnF (u).
CG-Verfahren Ax + b = 0 . . . .
Start: u
0, r
0= Au
0+ b, T OL
1. Schritt: (Steilster Abstieg) i p
1= −r
0ii ρ
1=
(p(r0,r0)1,Ap1)
iii u
1= u
0+ ρ
1p
1iv r
1= r
0+ ρ
1Ap
1 k. Schritt: (k ≥ 2 , konjugierter Gradient) i e
k−1=
(r(rk−1,rk−1)k−2,rk−2)
ii p
k= −r
k−1+ e
k−1p
k−1iii ρ
k=
(r(pk−1,rk−1)k,Apk)
iv u
k= u
k−1+ ρ
kp
kv r
k= r
k−1+ ρ
kAp
k Abbruchkriterium: ∣∣r
k∣∣ ≤ T OL∣∣r
0∣∣
Aufwand: O(n) Iterationen (typisch aber: √
n). Jeder Schritt O(n
2) Operationen, O(n) bei sparse-Matrix.
Absch¨ atzung /obere Schranke: ∣∣u
k−x∣∣ ≤ 2α
k∣∣u
0−x∣∣ mit α =
√κA−1
√κA+1
/ Gesucht: obere Schranke der Anzahl Iterationen k, um den absoluten Anfangsfehler um den Faktor c zu reduzieren, mit κ
Agegeben.
k =
ln(0.5⋅c)ln(α)1
f u n c t i o n[ x , it , t i m e ]= m y _ c g ( A , b , u0 , maxit , tol )
2tic; % s t a r t m e a s u r i n g t i m e
3u = u0 ; % s t a r t w i t h i n i t i a l g u e s s
4r0 = A * u0 + b ;
5
p = - r0 ;
6r = r0 ;
7it =0;
8
w h i l e ( it < m a x i t )
9
it = it +1;
10
rho =( r ’* r ) /( p ’*( A * p ) ) ;
11u = u + rho * p ;
12
r _ o l d = r ;
13r = r + rho *( A * p ) ;
14
if ( n o r m ( r ) < tol *n o r m ( r0 ) )
15b r e a k; % c o n v e r g e d
16
end
17
e =( r ’* r ) /( r_old ’* r _ o l d ) ;
18p = - r + e * p ;
19
end
20x = u ;
21
t i m e = toc; % s t o p m e a s u r i n g t i m e
22if ( it == m a x i t )
23
e r r o r ([’ no c o n v e r g e n c e a f t e r ’ , i n t 2 s t r( it ) , ’ i t e r a t i o n s ’]) ;
24
end
>> [x,flag,relres,it]=pcg(A,b,tol,maxit) L¨ ost Ax = b!
Vorkonditionierung: Mit unvollst¨ andiger Cholesky-Zerlegung die Kondition von A verkleinern.
>> H=cholinc(A,1e-3)
>> [x,flag,relres,it]= pcg(A,b,tol,maxit,H’,H)
3 Nichtlineare Gleichungssysteme
3.1 Eine Gleichung in einer Unbekannten
Gegeben: Stetige Funktion y = f(x).
Gesucht: L¨ osung x
∗der Gleichung f(x) = 0 (Nullstelle).
F¨ ur ∣f
′(x∗)∣ ≪ 1 ist das Problem schlecht konditioniert:
x∗ = f
−1(0) = H(0) κ
H= ∣
H′(0)
H(0)
∣ = ∣
x∗f′1(x∗)∣
Die Konvergenz der Fixpunkt-Iteration und des Newton-Verfahrens werden mit dem Banachschen Fixpunktsatz untersucht. Sie konvergieren nur wenn der Fixpunktsatz erf¨ ullt ist.
3.1.1 Fixpunkt-Iteration
Gegeben: y = f (x), x ∈ [a, b]
Gesucht: L¨ osung der Fixpunktgleichung x = F(x) ⇒ x
k+1= F (x
k)
Abbruchkriterium: ∣x
k+1− x
k∣ ≤ ∣x
k+1∣ ⋅ RT OL + AT OL
Die Fixpunktgleichung erh¨ alt man durch Umformung (Addition, usw.) der Funktionsgleichung f(x) = 0. Die Fixpunktgleichungen sind nicht eindeutig, es gibt meistens mehrere verschiedene Arten die Gleichung darzustellen.
3.1.2 Newton-Verfahren (1D)
Gegeben: Stetige Funktion y = f(x)
Gesucht: L¨ osung x
∗der Gleichung f(x) = 0 (Nullstelle)
Idee: Ersetze Graph von f(x) durch Tangente in P (x
0, f(x
0))
Newton-Iteration in 1D . . . .
Start: x
0, f
′(x), RT OL, AT OL
Vorgehen: x
k+1= F (x
k) = x
k−
f(xk)f′(xk)
Abbruchkriterium: ∣x
k+1− x
k∣ ≤ ∣x
k+1∣ ⋅ RT OL + AT OL
⊞ schnell
⊟ lokal, teuer, f
′(x) muss bekannt sein
3.1.3 Banachscher Fixpunktsatz Folgende Bedingungen m¨ ussen erf¨ ullt sein:
F bidet das Intervall I = [a, b] in sich ab. Umkehrung m¨ oglich.
F ist eine Kontraktion: ∃ 0 < L < 1 L ≥ ∣
F(x1)−F(x2) x1−x2
∣ Falls F
′stetig ist auf I gen¨ ugt ∣F
′∣ ≤ L < 1
▸ Falls F
′′in ganz I das gleiche Vorzeichen hat, nur ∣F
′(a)∣,∣F
′(b)∣
betrachten, sonst auch Maxima @ F
′′= 0 Daraus folgt dann:
F hat genau einen Fixpunkt x in [a, b]
Es gelten folgende Fehlerabsch¨ atzungen
∣x − x
k∣ ≤
Lk
1−L
∣x
1− x
0∣ a priori
∣x − x
k∣ ≤
1−LL∣x
k− x
k−1∣ a posteriori
Die a priori Absch¨ atzung wird vor allem dazu benutzt nach nur einer Iteration bereits eine obere Schranke f¨ ur die Zahl der Iterationen ang- zugeben. Die ben¨ otigt wird um x bis auf einen Fehler ε zu bestimmen.
∣x − x
k∣ ≤
Lk
1−L
∣x
1− x
0∣ ≤ ε ⇒ k ≥
ln∣xε(1−L) 1−x0∣ lnL
Es gibt anziehende- und abstossende Fixpunkte
∣F
′(x)∣ < 1, so ist x anziehend
∣F
′(x)∣ > 1, so ist x abstossend
∣F
′(x)∣ = 1, so kann x anziehend, abstossend oder keines von beiden sein Je kleiner ∣F
′(x)∣ ist, desto schneller konvergiert das Verfahren. Die selben Bedingungen gelten f¨ ur die inverse Iteration f¨ ur (F
−1)
′.
3.1.4 Konvergenzordnung p
∣x − x
n+1∣ ≅ C∣x − x
n∣
pCG-Verfahren: p = 1 Fixpunktiteration: p = 1 Newton-Verfahren: p = 2 Sekantenmethode: p = 1.6 Bisektionsverfahren: p = 1
3.1.5 Effizienzindex E
E = p
1/mwobei m die Zahl der Funktionsauswertungen in jedem Schritt bedeutet.
3.1.6 Die Sekantenmethode
Sekantenmethode . . . .
Start: x
0, x
1, RT OL, AT OL
Vorgehen: x
k+1=
xk−1f(xf(xk)−xkf(xk−1)k)−f(xk−1)
Abbruchkriterium: ∣x
k+1− x
k∣ ≤ ∣x
k+1∣ ⋅ RT OL + AT OL
⊞ braucht keine Ableitung, billiger als Newton
⊟ lokal, langsamer als Newton
3.1.7 Das Bisektionsverfahren
Gegeben: f(x), stetig im Intervall [a, b] und f (a) ⋅ f(b) < 0
Bisektionsverfahren (Divide and Conquer) . . . .
Start: a
0, b
0, x
0=
a0+b02
, x
1, RT OL, AT OL
Vorgehen:
i if f(x
k) = 0 then break
ii if f(a
k) ⋅ f(x
k) < 0 then a
k+1= a
k, b
k+1= x
kelse a
k+1= x
k, b
k+1= b
kx
k+1=
ak+1+bk+12
Abbruchkriterium: ∣x
k+1− x
k∣ ≤ ∣x
k+1∣ ⋅ RT OL + AT OL
⊞ global
⊟ langsame Konvergenz
3.2 Mehrere Gleichungen mit mehreren Unbekannten
Gegeben: f(x) = 0 mit x =
⎛
⎜ ⎜
⎜
⎝ x
1. . x
n⎞
⎟ ⎟
⎟
⎠ f (x) =
⎛
⎜ ⎜
⎜
⎝
f
1(x1, . . . , x
n) . . f
n(x
1, . . . , x
n)
⎞
⎟ ⎟
⎟
⎠
=
⎛
⎜ ⎜
⎜
⎝ 0 . . 0
⎞
⎟ ⎟
⎟
⎠ Jacobi-Matrix: J(x) =
∂f∂x=
⎛
⎜ ⎜
⎝
∂f1
∂x1
∂f1
∂x2
. . .
∂x∂f1n
.. ..
∂fn
∂x1
∂fn
∂x2
. . .
∂x∂fnn
⎞
⎟ ⎟
⎠
⇒ Linearisierung von f in x
03.2.1 Newton Verfahren (nD)
Das Newton-Verfahren ist immer lokal konvergent, falls det(J(x
∗)) ≠ 0 Es konvergiert quadratisch. Es gilt der Banachsche Fixpunktsatz, ersetze ∣.∣
durch ∣∣.∣∣
Newtonverfahren in R
n. . . .
Start: x
0, RT OL, AT OL
Vorgehen:
i J(x
k)∆
k= −f (x
k) ⇒ ∆
k= J(x
k)/ − f (x
k) ii x
k+1∶= x
k+ ∆
k Abbruchkriterium: ∣∣∆
k∣∣ ≤ ∣∣x
k+1∣∣ ⋅ RT OL + AT OL
1
f u n c t i o n[ x , it ]= m y _ n e w t o n ( x0 , rtol , atol , m a x i t )
2it =0; x = x0 ;
3
w h i l e ( it < m a x i t )
4d e l t a = - J ( x ) \ f ( x ) ;
5x _ o l d = x ;
6
x = x _ o l d + d e l t a ;
7
it = it +1;
8
if ( n o r m ( d e l t a ) <= n o r m ( x ) * r t o l + a t o l )
9
b r e a k; % c o n v e r g e d
10
end
11
end
12
if ( it == m a x i t )
13
e r r o r ([’ no c o n v e r g e n c e a f t e r ’ , i n t 2 s t r( it ) , ’ i t e r a t i o n s ’]) ;
14
end;
15
end
16
f u n c t i o n[ f_ ]= f ( x ) % f ( x ) =0
17x1 = x (1) ; x2 = x (2) ;
18
f_ =[ x1 + x2 ^3 ; x1 ^2+ x2 ];
19
end
20
f u n c t i o n[ J_ ]= J ( x )
21x1 = x (1) ; x2 = x (2) ;
22
J_ =[1 3* x2 ^2 ; 2* x1 1];
23
end
⊞ quadratische Konvergenz
⊟ Finden eines guten Startvektors x
0.
⊟ Berechnen der Jacobi-Matrix in jedem Schritt.
3.2.2 Quasi-Newton Verfahren (nD)
In jedem Schritt wird die gleiche Jacobi-Matrix J(x
0) verwendet.
1
f u n c t i o n[ x , it ]= m y _ q u a s i n e w t o n ( x0 , rtol , m a x i t )
2it =0; x = x0 ;
3
J0 = J ( x0 ) ; % < - -
4
w h i l e ( it < m a x i t )
5
d e l t a = - J0 \ f ( x ) ; % < - -
6
[ . . . ] % s a m e as m y _ n e w t o n
⊞ J nur noch einmal berechnen.
⊟ nur noch lineare Konvergenz
3.2.3 ged¨ ampftes Newton Verfahren (nD) Wie Newton, aber mit D¨ ampfungsfaktor α
k.
x
k+1∶= x
k+ α
k∆
kα
k,start≪ 1 α
k,ende=1⊞ gr¨ osserer lokaler Konvergenzbereich durch weniger ¨ Uberschiessen.
⊟ Durch D¨ ampfung aber langsamer.
4 Ausgleichsrechnung
Gesucht wird ein Vektor x, so dass die dazugeh¨ origen Residuen r minimal sind.
4.1 Lineare Ausgleichsrechnung
4.1.1 mit Normalengleichungen nach Gauss i Fehlergleichungen: Ax − c = r
ii Normalengleichungen: A
TA
²
A∗
x = A
Tc >> x=(A’A)\(A’c)
⊟ A
∗meist schlecht konditioniert ⇒ QR-Zerlegung
4.1.2 mit QR-Zerlegung
QR-Zerlegung von A aus Ax − c = r . . . . i QR-Zerlegung von A: A ↝ R c ↝ d
A
k+1= U
pqT⋅ A
kc
k+1= U
pqT⋅ c
k} bis A quadratisch, dann A = R und c = d U
pq=
p → q →
⎛
⎜
⎝
cos φ 0 sinφ
0 1 0
− sinφ 0 cos φ
⎞
⎟
⎠
sinφ = −
√ A(q,p) A(p,p)2+A(q,p)2cosφ =
√ A(p,p) A(p,p)2+A(q,p)2ii R¨ uckw¨ artseinsetzen: Rx = d nach x
>> [Q,R]=qr(A) >> d=Q’c >> x=R0\d0 mit R0 quadratisch.
⊞ κ
Gauss= κ(A
TA) =
µµmaxmin
κ
QR= κ(A) =
√ κ(A
TA)
4.1.3 mit Singul¨ arwertzerlegung A = U SV
T Gegeben: Fehlergleichungen Ax − c = r
1
f u n c t i o n[ x , y ]= m y _ s v d ( A , c )
2[ u , s , v ]= svd( A ) ;
3
k = r a n k ( A ) ;
4
[ rows , c o l s ]= s i z e ( A ) ;
5
y =[0 0] ’; % y to be a c o l u m n v e c t o r
6for i =1: k
7
y ( i ) =1/ s ( i , i ) * u (: , i ) ’* c ;
8end
9
for i = k +1: c o l s
10
y ( i ) =0; % a r b i t r a r y , c h o s e n to be 0
11end
12
x = v * y ;
4.2 Nichtlineare Ausgleichsrechnung
Wie bei der linearen Ausgleichsrechnung ist die Kondition von A
TA zu gross, weshalb man besser mit den Fehlergleichungen rechnet.
4.2.1 Gauss-Newton-Methode
Fehlergleichungen: f(x) − c = r
Linearisierte Fehlergln.: A
0°
J@x0
ξ + f
0− c
´¹¹¹¹¹¸¹¹¹¹¹¶
d0
= ρ
0⇒ ξ
1= A
0/(ρ
0− d
0)
x
1= x
0+ ξ
1und wieder von vorne...
⊟ Je nach x
0keine Konvergenz → Minimierung.
4.2.2 Gauss-Newton-Methode mit Minimierung
Gleiches Vorgehen bis ξ
k+1, dann mit ̃ x = x
k+ tξ
k+1und t = 1,
12,
14, ...
testen, ob S(̃ x) < S(x
k) erf¨ ullt ist und bei ∣S(̃ x) − S(x
k)∣ < T OL den Vorschlag ̃ x akzeptieren: x
k+1= ̃ x. (S(x) = r
Tr)
⊞ Konvergenz garantiert, dank S(̃ x) < S(x
k)
⊟ Langsame Konvergenz am Anfang m¨ oglich, aber am Ende doch wieder
fast quadratisch.
5 Interpolation und Approximation
5.1 Das Interpolationspolynom
Gegeben: n + 1 St¨ utzstellen x
0, x
1, . . . , x
nund die St¨ utzwerte f
0= f (x
0), f
1= f (x
1), . . . , f
n= f (x
n).
Gesucht: Polynom ≤ n-ten Grades P
n(x) = a
0x
n+a
1x
n−1+ ⋅ ⋅ ⋅ +a
n−1x+
a
nmit P
n(x
0) = f
0, P
n(x
1) = f
1, . . . , P
n(x
n) = f
n5.1.1 Darstellung nach Lagrange
P
n(x) =
n
∑
i=0
f
il
i(x) l
i(x) =
n
∏
j=0,j≠i
x − x
jx
i− x
ji = 0, 1, . . . , n / Gegeben: 4 St¨ utzstellen und ihre Werte ⇒ n = 3
P
n(x) = ∑
ni=0f
il
i(x) (Falls f
i= 0 ⇒ l
inicht berechnen) l
0(x) =
(x(x−x1)(x−x2)(x−x3)0−x1)(x0−x2)(x0−x3)
l
1(x) =
(x(x−x0)(x−x2)(x−x3)1−x0)(x1−x2)(x1−x3)
l
2(x) =
(x(x−x0)(x−x1)(x−x3)2−x0)(x2−x1)(x2−x3)
l
3(x) =
(x(x−x0)(x−x1)(x−x2)3−x0)(x3−x1)(x3−x2)
5.1.2 Baryzentrsiche Darstellung
P
n(x) = ∑
ni=0µ
if
i∑
ni=0µ
iλ
i∶=
1
∏
nj=0,j≠i(x
i− x
j) µ
i∶=
λ
ix − x
imit St¨ utzkoeffizienten λ
i(Nenner von l
i(x)) und i = 0,1, . . . , n.
⊞ Bei verschiedenen Polynomen weniger aufwendig als Lagrange.
λ
i→ O(n
2) (1x); P
n(x) → O(n); bei Lagrange immer O(n
2).
5.1.3 Fehler des Interpolationspolynoms f(x) − P
n(x) = f
(n+1)(ξ)
(n + 1)!
n
∏
i=0
(x − x
i) = O(h
n+1) f(x) − P
n(x) ≤
f(n+1)(n+1)!(ξ)∏
ni=0(x − x
i) mit ξ = x wo Fehler maximal
5.2 Splineinterpolation
Die Funktion f(x) wird st¨ uckweise mit Polynomen 3.Grades Q
i(t) inter- poliert. Q
i(t) ∶= P
i(x
i+ h
it) mit t =
x−xihi
und h
i= x
i+1− x
i.
Q
i(t) = f
i(1 − 3t
2+ 2t
3) + f
i+1(3t
2− 2t
3) + h
if
i′(t − 2t
2+ t
3) +h
if
i+1′(−t
2+ t
3)
Q ˙
i(t) = f
i(6t+6t
2) +f
i+1(6t−6t
2) +h
if
i′(1−4t+2t
2) +h
if
i+1′(−2t+3t
2)
Q ¨
i(t) = f
i(−6 + 12t) + f
i+1(6 − 12t) + h
if
i′(−4 + 6t) + h
if
i+1′(−2 + 6t)
...
Q
i(t) = 12f
i− 12f
i+1+ 6h
if
i′+ 6h
if
i+1′ Q
i(0) = f
iQ
i(1) = f
i+1Q ˙
i(0) = h
if
i′Q ˙
i(1) = h
if
i+1′.
Sind die Ableitungen bekannt, handelt es sich um die Hermite- Interpolation und im Algorithmus beginnt man bei Schritt 2.
Sind die Ableitungen nicht bekannt, fehlen diese Gleichungen, man stellt daher zus¨ atzliche Forderungen:
1.Forderung: P
i′′(x
i+1) = P
i+1′′(x
i+1) ⇒
Q¨i(1) h2i
=
Q¨i+1(0) h2i+1
2.Forderung “not a knot“:
P
1(x) = P
2(x)
P
n−2(x) = P
n−1(x) } ⇒
⎧ ⎪
⎪ ⎪
⎪
⎨
⎪ ⎪
⎪ ⎪
⎩
Q
...
1(1) h31=
Q
...
2(0) h32 Q...
n−2(1)h3n−2
=
Q
...
n−1(0) h3n−1 2.Forderung “nat¨ urliche Randbedingung“:
P
1′′(x
1) = P
n−1′′(x
n) = 0 ⇒
Q¨1(0) h21
=
Q¨n−1(1) h2n−1
= 0
2.Forderung “periodische Funktion“:
P
1′′(x
1) = P
n−1′′(x
n) ⇒
Q¨1(0) h21
=
Q¨n−1(1) h2n−1
periodische Funktion ⇒ { f
1= f
nf
1′= f
n′Spline-Interpolationsfunktion g(x). . . . i Finde L¨ osung aus Af
′= d
↘ not a knot:
⎛
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎝ b
1 a12
b
1a
1b
2b
2a
2b
3... ... ...
b
n−2a
n−2b
n−1 an−22
b
n−1⎞
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎠
⎛
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎝ f
1′f
2′f
3′...
f
n−1′f
n′⎞
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎠
=
⎛
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎝ d
1d
2d
3...
d
n−1d
n⎞
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎠
↘ nat¨ urliche RB:
⎛
⎜ ⎜
⎜
⎜ ⎜
⎝
4 2
b
1a
1b
2... ... ...
b
n−2a
n−2b
n−12 4
⎞
⎟ ⎟
⎟
⎟ ⎟
⎠
⎛
⎜ ⎜
⎜
⎜ ⎜
⎝ f
1′f
2′...
f
n−1′f
n′⎞
⎟ ⎟
⎟
⎟ ⎟
⎠
=
⎛
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜
⎝
6(f1−f2) h1
d
2...
d
n−16(fn−fn−1) hn−1
⎞
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟
⎠
↘ periodische RB, h = const.:
⎛
⎜ ⎜
⎜ ⎜
⎜
⎝
8 2 2
b a b
... ... ...
b a b
b b a
⎞
⎟ ⎟
⎟ ⎟
⎟
⎠
⎛
⎜ ⎜
⎜ ⎜
⎜
⎝ f
1′f
2′...
f
n−2′f
n−1′⎞
⎟ ⎟
⎟ ⎟
⎟
⎠
=
⎛
⎜ ⎜
⎜ ⎜
⎜
⎝
6
h
(f
2− f
n−1) d
2...
d
n−2d
n−1⎞
⎟ ⎟
⎟ ⎟
⎟
⎠ h
i∶= x
i+1− x
i, i = 1, . . . , n − 1
b
i∶=
1hi
, i = 1, . . . , n − 1 a
i∶= 2(b
i+ b
i+1), i = 1, . . . , n − 2 c
i∶=
fi+1−fih2i
, i = 1, . . . , n − 1 d
1∶= 2c
1+
hh11+h2
(c
1+ c
2) (nur bei “not a knot“) d
i∶= 3(c
i−1+ c
i), i = 2, . . . , n − 1
d
n∶= 2c
n−1+
hn−1hn−1+hn−2
(c
n−1+ c
n−2) (nur bei “not a knot“) ii Bestimme den Index i, f¨ ur den gilt x
i≤ x ≤ x
i+1iii Setze t =
x−xihi
iv Berechne Qi(t) = α
0+ [β
0+ (γ
0+ δ
0t)(t − 1)]t , wobei β
−1= h
if
i′α
0= f
iγ
0= β
0− β
−1β
0= α
1− α
0δ
0= γ
1− γ
0α
1= f
i+1γ
1= β
1− β
0β
1= h
if
i+1′v Setze g(x) = Q
i(t).
Allgemeines Vorgehen beim L¨ osen eines Problems:
1 Entscheiden, welche 2.Forderung gew¨ ahlt wird ⇒ Gleichunssystem hin- schreiben.
2 Tabelle erstellen, um den Vektor der rechten Seite d
izu finden. Glei- chungssystem mit TR::rref() l¨ osen.
3 Aus f
i′per Hermiteschen Algorithmus (ii bis v) die gesuchte Funktion g(x) finden, wobei g(x) = Qi(t) = α
0+ [β
0+ (γ
0+ δ
0t)(t − 1)]t mit TR::qi(α
0, β
0, γ
0, δ
0, t).
1
f u n c t i o n[ yy ]= m y _ s p l i n e _ n o t a k n o t ( x , fx , xx )
2h = d i f f ( x ) ;
3
b = 1 . / h ;
4
a = 2 * ( b (1: end -1) + b (2: end ) ) ;
5c = d i f f ( fx ) ./ h . ^ 2 ;
6
d = [ 2 * c (1) + h (1) /( h (1) + h (2) ) *( c (1) + c (2) ) ,...
7
3*( c (1: end -1) + c (2: end) ) ,...
8
2* c ( end) + h ( end ) /( h (end -1) + h ( end) ) * . . .
9
( c (end) + c ( end -1) ) ];
10
A = s p d i a g s ([[ b (1: end -1) ’; a ( end) / 2 ; 1 ] . . .
11
[ b (1) ; a ’; b (end ) ] . . .
12
[1; a (1) /2; b (1: end -1) ’]] ,...
13
-1:1 , l e n g t h( x ) , l e n g t h( x ) ) ;
14f _ p r i m e = A \ d ’;
15
for k =1: l e n g t h( xx )
16
i = min( f i n d (( xx ( k ) - x ) <0) ) -1;
17
t =( xx ( k ) - x ( i ) ) / h ( i ) ;
18a l p h a =[ fx ( i ) fx ( i +1) ];
19
b e t a =[ h ( i ) * f _ p r i m e ( i ) d i f f ( a l p h a ) ...
20
h ( i ) * f _ p r i m e ( i +1) ];
21
g a m m a = d i f f ( b e t a ) ;
22d e l t a = d i f f ( g a m m a ) ;
23
yy ( k ) = a l p h a (1) +( b e t a (2) + . . .
24
( g a m m a (1) + d e l t a (1) * t ) *( t -1) ) * t ;
25end
>> [yy]= spline(x,fx,xx) ≡ my spline notaknot.m 5.2.1 Interpolationsfehler
Der Interpolationsfehler ist von der Ordnung O(h
4). Verglichen mit dem Interpolationspolynom O(h
n+1) ist das viel besser, je gr¨ osser n ist. Beim Interpolationspolynom f¨ ur n gross hat es zwischen den St¨ utzstellen Extre- malwerte, die gegen den Rand und mit zunehmendem n immer gr¨ osser werden. Dieses Verhalten zeigt die Splineinterpolation nicht.
5.3 Trigonometrische Interpolation
Diskrete Fourier-Transformation (DFT) und Fast Fourier Transformation (FFT) spielen eine wichtige Rolle in der Signal- und Bildverarbeitung, im besonderen auch bei der Daten-Kompression.
Problemstellung: Es sind N St¨ utzstellen x
ksowie deren St¨ utzwerte f
keiner 2π-periodischen Funktion gegeben.
Gesucht: ein trigonometrisches Polynom
p(x) =
a20+ ∑
N/2−1j=1[a
jcos(jx) + b
jsin(jx)] +
aN/22cos (
N2
x)
5.3.1 DFT
Fourier-Reihe von f : f (x) = ∑
∞j=−∞c
je
ijxc
j=
12π
∫
2π
0
f (x)e
−ijxdx Dieses Integral kann nat¨ urlich nicht gel¨ ost werden, da die Funtkion f(x) nur an N Stellen bekannt ist ⇒ Approximation des Integrals durch Tra- pezn¨ aherung c ˜
j=
N1∑
N−1l=0f (x
l)e
−ijxl, mit x
l=
l2πN.
Analyse: ˜ c
(N)=
1N
W f
(N)Synthese: f
(N)= W ˜ c
(N)mit f
(N)=
⎛
⎜
⎝ f
0⋮ f
N−1⎞
⎟
⎠
˜ c
(N)=
⎛
⎜
⎝
˜ c
0⋮
˜ c
N−1⎞
⎟
⎠
und W =
⎛
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎝
1 1 1 ⋯ 1
1 w w
2⋯ w
N−11 w
2w
4⋯ w
2(N−1)⋮ ⋮ ⋮ ⋱ ⋮
1 w
N−1w
2(N−1)⋯ w
(N−1)2⎞
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎠
, wobei w = e
−i2πNund W das konjugiert komplexe von W . trigonometrische Interpolationspolynome
komplex: p(x) ∶= ∑
N/2+1j=−N/2+1˜ c
je
ijx+ ˜ c
N/2cos(
N2x)
2π-periodisch:
⎧ ⎪
⎪ ⎪
⎨
⎪ ⎪
⎪ ⎩
p(x)
3∶= ˜ c
0+ c ˜
1e
ix+ ˜ c
2e
−ixp(x)
5∶= ˜ c
0+ c ˜
1e
ix+ ˜ c
2e
−ix+ ˜ c
3e
2ix+ ˜ c
4e
−2ix. . .
reell: p(x) ∶=
a20+ ∑
N/2+1j=1[a
jcos(jx) + b
jsin(jx)] +
aN/22cos(
N2x) Allgemeines Vorgehen:
1 Diskrete Fourier-Analyse ˜ c
(N)=
N1W f
(N). 2 Auswertung des Polynoms p(x).
/ Bestimme das interpolierende trigonometrische Polynom von der 2π- periodischen Funktion mit x
i0
2π3 4π3f
if
0f
1f
2˜ c
(3)=
13
W f
(3)=
13
⎛
⎜
⎝
1 1 1
1 w w
21 w
2w
4⎞
⎟
⎠
⎛
⎜
⎝ f
0f
1f
2⎞
⎟
⎠
=
⎛
⎜ ⎜
⎜
⎝
f0+f1+f2 3 f0+wf1+w2f2
3 f0+w2f1+w4f2
3
⎞
⎟ ⎟
⎟
⎠ mit
⎧ ⎪
⎪ ⎪
⎪ ⎪
⎨
⎪ ⎪
⎪ ⎪
⎪ ⎩
w = e
−i2πN= e
−i2π3= −
12
−
√3 2
i w
2= e
−2i2πN= e
−i4π3= −
12
+
√3 2
i w
4= w = e
−i2π3= −
12−
√3 2
i
˜ c
(3)=
⎛
⎜ ⎜
⎜ ⎜
⎝
f0+f1+f2 3
f0+f1(−12−√23i)+f2(−12+√23i) 3
f0+f1(−12+√23i)+f2(−12−√23i) 3
⎞
⎟ ⎟
⎟ ⎟
⎠
p(x) = ˜ c
0+ ˜ c
1e
ix+ ˜ c
2e
−ix= ˜ c
0+ (˜ c
1+ c ˜
2) cos(x) + i(˜ c
1− ˜ c
2)sin(x) mit
⎧ ⎪
⎪ ⎪
⎪ ⎪
⎨
⎪ ⎪
⎪ ⎪
⎪ ⎩
˜
c
1+ ˜ c
2=
2f0−f1−f23
˜
c
1− ˜ c
2=
−i√3f1+i√ 3f2 3
i(˜ c
1− ˜ c
2) =
√3f1−√ 3f2 3
p(x) =
f0+f31+f2+
2f0−f1−f23
cos(x) +
√3f1−√ 3f2 3
sin(x)
5.3.2 FFT
Sei γ
(N)= W f
(N)= N˜ c
(N)und N = 2n , womit w
N= 1 und w
n= −1.
gerade approximative Fourier-Koeffizienten: γ
2k= ∑
n−1j=0(w
2)
kj(f
j+ f
j+n) ungerade approx. Fourier-Koeffizienten: γ
2k+1= ∑
n−1j=0(w
2)
kj(f
j−f
j+n)w
jDie Anzahl komplexer Multiplikationen betr¨ agt µ =
N2
log
2(
N2
).
Wir betrachten den Fall N = 2
m, hier konkret: m = 3, N = 8, n = 4.
Es gilt: w = e
−i2πN, w
8= 1, w
4= −1
W
(N)=
⎛
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜
⎝ γ
0γ
2γ
4γ
6γ
1γ
3γ
5γ
7⎞
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟
⎠
=
⎛
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜
⎝
1 1 1 1 1 1 1 1
1 w
2w
4w
61 w
2w
4w
61 w
41 w
41 w
41 w
41 w
6w
4w
21 w
6w
4w
21 w w
2w
3w
4w
5w
6w
71 w
3w
6w w
4w
7w
2w
51 w
5w
2w
7w
4w w
6w
31 w
7w
6w
5w
4w
3w
2w
⎞
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟
⎠ Das ganze faktorisiert ergibt: W ̂
(N)= ( W
(n)0
0 W
(n)) D
(N)W ̂
(N)=
⎛
⎜ ⎜
⎜ ⎜
⎜
⎜ ⎜
⎜ ⎜
⎜
⎜ ⎜
⎝
1 1 1 1
1 w
2w
4w
61 w
41 w
41 w
6w
4w
21 1 1 1
1 w
2w
4w
61 w
41 w
41 w
6w
4w
2⎞
⎟ ⎟
⎟ ⎟
⎟
⎟ ⎟
⎟ ⎟
⎟
⎟ ⎟
⎠
⎛
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎜ ⎜
⎝
1 1
1 1
1 1
1 1
1 w
4w w
5w
2w
6w
3w
7⎞
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎟ ⎟
⎠ mit
⎧ ⎪
⎪ ⎪
⎪ ⎪
⎨
⎪ ⎪
⎪ ⎪
⎪ ⎩ w
4= −1 w
5= −w w
6= −w
2w
7= −w
3Die Matrixmultiplikation z = D
(N)f
(N)l¨ asst sich einfach durchf¨ uhren. Die ubriggebliebene Rechnung ¨ ̂ γ
(N)= ( W
(n)0
0 W
(n)) z
(N)l¨ asst sich wie- derum auf zwei diskrete Fourier-Transformationen der Ordnung n = 4, im n¨ achsten Schritt weitere R¨ uckf¨ uhrung auf n = 2 und dann n = 1
1
f u n c t i o n []= m y _ f f t
2N = 2 0 ; m =5; M = N *2^ m ;
3
% N b i g - - > m o r e i n i t i a l d a t a
4
% m , M b i g - - > m o r e i n t e r p o l a t i o n p o i n t s
5x_k =2*pi/ N * [ 0 : N -1] ’; % i n i t i a l : n p o i n t s
6f_k =sin (4* x_k ) . ^ 2 ; % g i v e n ( e x a m p l e )
7c = fft( f_k / N ) ; % a n a l y s i s
8
c _ s t a r =[ c (1: N /2) ;z e r o s ( M - N ,1) ; c ( N / 2 + 1 : end ) ];
9
x _ s t a r =2*pi/ M * [ 0 : M -1] ’; % n e w : m > n p o i n t s
10f _ s t a r = M *i f f t ( c _ s t a r ) ; % s y n t h e s i s
⊞ Aufwand fft: O(N log
2N) Aufwand dft: O(N
2)
6 Numerische Integration und Differentiation
6.1 Numerische Integration - Quadratur
Bei der numerischen Integration soll das Integral I = ∫
abf (x)dx mit ̃ I ap- proximiert werden. Es werden nun einige dieser Verfahren vorgestellt.
6.1.1 Trapezmethode
Idee: Unterteilung der Funktion in n Intervalle der L¨ ange h =
b−an
und approximiere linear mit T (h) =
h2[f
a+ f
b]
I ̃ = T (h) = h
2 [f
0+ f
1] + h
2 [f
1+ f
2] + ⋯ + h
2 [f
n−1+ f
n]
= h [ 1
2 f
0+ f
1+ ⋯ + f
n−1+ 1 2 f
n]
Das Trapezverfahren approximiert mind. Polynome des 1. Grades exakt.
Absch¨ atzung: ∣I − T (h)∣ ≤
M12(b − a)h
2, M ≥ ∣f
′′(x)∣, x ∈ [a, b]
Das Trapezverfahren hat Ordnung 2.
Trapezverfahren mit Schritthalbierung . . . .
Start: a, b, RT OL, AT OL
1.Schritt:
i h
0= b − a ii s
0=
12
(f(a) + f(b)) iii T
0= s
0h
0iv N
0= 1
weitere Schritte: (n = 0, 1,2, . . .) i h
n+1=
hn2
ii s
n+1= s
n+ ∑
Nj=1nf(a + (2j − 1)h
n+1) iii T
n+1= h
n+1s
n+1iv N
n+1= 2N
n Abbruchbedingung: ∣T
n+1− T
n∣ ≤ ∣T
n+1∣ ⋅ RT OL + AT OL
6.1.2 Simpson’sche Formel
Idee: Unterteilung der Funktion in 2n Intervalle der L¨ ange h =
b−a2n
und
approximiere quadratisch mit S(h) =
h3[f
a+ 4f
c+ f
b]
I ˜ = S(h) = h
3 [f
0+ 4f
1+ f
2] + h
3 [f
2+ 4f
3+ f
4] + ⋅ ⋅ ⋅ +
h
3 [f
2n−2+ 4f
2n−1+ f
2n]
= h
3 [f
0+ 4f
1+ 2f
2+ 4f
3+ 2f
4+ ⋅ ⋅ ⋅ + 2f
2n−2+ 4f
2n−1+ f
2n]
Die Simpson-Methode approximiert mindestens Polynome des 3. Grades exakt.
Absch¨ atzung: ∣I − S(h)∣ ≤
180M(b − a)h
4, M ≥ ∣f
(4)(x)∣, x ∈ [a, b]
Die Simpson-Methode hat Ordnung 4.
Simpson-Methode mit Trapezwerten . . . .
Start: a, b, RT OL, AT OL
Berechnung der Trapezwerte: T
0, T
1, T
2, . . .
Berechnung der Simpsonwerte:
S
1=
4T13−T0, S
2=
4T23−T1, S
3=
4T33−T2, . . .
Abbruchbedingung: ∣S
n+1− S
n∣ ≤ ∣S
n+1∣ ⋅ RT OL + AT OL
6.1.3 Romberg-Verfahren
Idee: Durch Kombination von verschiedenen Trapezwerten kann man Fehlerterme tiefer Ordnung eliminieren und so die Ordnung des Verfah- rens erh¨ ohen → Simpsonwerte. Mit diesen verf¨ ahrt man genauso...:
R
0,0= T (h) = I + c
1h
2+c
2h
4+ . . . T (
h2
) = I +
14
c
1h
2+
116
c
2h
4+. . . R
1,1= S
1= S (
h2
) =
4T(h 2)−T(h)
3
=
T(h2)−4−1T(h) 1−4−1
= I −
14
c
2h
4+ O(h
6) R
2,2=
16S(h 4)−S(h2)
15
=
S(h4)−4−2S(h2)
1−4−2
= I + O(h
6)
Romberg-Verfahren . . . .
Start:
h
0= b − a, h
1=
h02
, h
2=
h12
, . . . RT OL, AT OL
Romberg-Verfahren:
R
j,0= T
jR
j,k=
Rj,k−1−4−kRj−1,k−1 1−4−k
Abbruchbedingung: ∣R
j,j− R
j,j−1∣ ≤ ∣R
j,j∣ ⋅ RT OL + AT OL
6.1.4 Guass’sche Quadraturformeln
Die Gauss’sche Quadraturformel gilt f¨ ur das Integral I = ∫
−11f(x)dx. Das allgemeine Integral I = ∫
abg(x)dx muss daher in diese Form transformiert werden.
Die n-Punkt Quadraturformel lautet:
I ˜ = Q
n=
n
∑
j=1
w
jf
j, wobei die Funtionswerte f
jund die Gewichte w
jf(x) = b − a 2 g (
b − a 2 x +
a + b 2 ) w
j= ∫
1
−1
⎡ ⎢
⎢ ⎢
⎢ ⎣
n
∏
k=1,k≠j
( x − x
kx
j− x
k)
2
⎤
⎥
⎥ ⎥
⎥ ⎦
dx > 0 j = 1,2, . . . , n
⊞ Eine n-Punkt-Quadraturformel hat Genauigkeitsgrad von (2n-1), wenn die Nullstellen der Legende-Polynome verwendet werden.
⊞ Es werden viel weniger Funktionsaufrufe ben¨ otigt.
⊟ Aber daf¨ ur m¨ ussen viele Funktionswerte bekannt sein.
6.2 Numerische Differentiation
Notwendig ist numerische Differentiation, wenn nur einige Werte der Funk- tion bekannt sind. Mit der Talyorentwicklung um z:
f (z + h) = f(z) +
1!hf
′(z) +
h2!2f
′′(z) + ⋅ ⋅ ⋅ +
hk!kf
(k)(z) f (z − h) = f(z) −
1!hf
′(z) +
h2!2f
′′(z) − . . .
...lassen sich Approximationen f¨ ur f
′(z) herleiten:
Vorw¨ arts-Differenzenquotient:
f(z+h)−fh (z)= f
′(z) +
h2f
′′+ O(h
2) R¨ uckw¨ arts-Differenzenquotient:
f(z)−f(z−h)h= f
′(z) −
h2f
′′+ O(h
2) Symmetrische Differenzquotienten der Ordnung 1 , 2 und n:
∆
1h(z) = f (z + h) − f(z − h)
2h = f
′(z) + h
26 f
′′′(z) + O(h
3)
∆
2h(z) = f (z + h) − 2f (z) + f(z − h)
h
2= f
′′+ O(h
2)
∆
nh(z) = 1 (2h)
nn
∑
j=0
(−1)
ja
jf (z + b
jh) a
j= ( n
j ) b
j= n − 2j mit dem Binomialkoeffizienten a
jTR::ncr(n,j).
F¨ ur grosse h ist das Ergebnis schlecht, doch auch zu kleine h resultieren in schlechten Ergebnissen aufgrund Ausl¨ oschung.
h
optimal≅
√
10
−d⋅ 2
∣f∣f(z)∣′′(z)∣, d-stellige Gleitpunktarithmetik
7 Gew¨ ohnliche Differentialgleichungen
Gegeben: Die DGL x ˙ = f (t, x), sowie der Anfangswert x(t
0) = x
0. Gesucht: Die Approximation an der Endstelle ̃ x(t
f).
7.1 Explizite Einschrittverfahren 7.1.1 Das explizite Eulerverfahren
Wir approximieren x(t + h) durch das Taylorpolynom vom Grad 1:
x(t) + x(t)h. Per Definition ist ˙ x(t) = ˙ f (t, x(t)) und somit F (t, x, h) ∶= x + hf (t, x).
Das Eulerverfahren ist wie folgt definiert:
̃ x
j+1= F (t
j,̃ x
j, h
j) = ̃ x
j+h
jf (t
j,̃ x
j) x ˜
0= x0 j = 0, 1, . . . , n − 1
Bei ¨ aquidistanten Schritten gilt: h ∶=
tf−t0n
t
j∶= t
0+ jh.
1
f u n c t i o n[ x _ t f ]= m y _ e e u l e r _ m a i n
2
f1 = @ ( x , t ) x ^2+ t ^2; % f u n c t i o n h a n d l e
3
h = 0 . 1 ; % ^ - - on f = x p r i m e
4
x0 =0;
5
t0 =0; tf =1;
6
n =( tf - t0 ) / h ;
7
x _ t f = m y _ e e u l e r ( f1 , t0 , x0 , h , n ) ;
1
f u n c t i o n[ x ]= m y _ e e u l e r ( f , t0 , x0 , h , n )
2x = x0 ;
3
t = t0 ;
4for it =1: n
5x = x + h * f ( x , t )
6
t = t + h ;
7
end
Lokaler Fehler bei j + 1: l(t
j,̃ x
j, h) ∶= F (t
j,̃ x
j, h)
´¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¸¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¹¶
̃ xj+1