16.346 Astrodynamics MIT OpenCourseWare .

advertisement
MIT OpenCourseWare
http://ocw.mit.edu
16.346 Astrodynamics
Fall 2008
For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.
Lecture 33 Runge-Kutta Method of Numerical Integration # 12
Numerical Integration
dr
=v
dt
dv
= g(r)
dt
=⇒
dx
=y
dt
dy
= f(x)
dt
x(t0 ) = x0
⇐⇒
y(t0 ) = y0
dxi
= yi
dt
dy i
= f i (xi )
dt
i = 1, 2, 3
f(x0 ) = f0
Taylor Series Expansion
�
�
h2
dx ��
h2 d2 x ��
+
+
·
·
·
=
x
+
hy
+
f +
· · · x(t + h) = x0 + h
0
0
2!
dt2 �
t=t0
2!
0
dt
�
t=t0
�
�
dy ��
h2 d2 y ��
h2 y(t + h) = y0 + h
+
+
·
·
·
=
y
+
hf
f +
· · · +
0
0
2!
dt2 �
t=t0
2!
0
dt
�
t=t0
�
h2 ∂f dx ��
+
· · · = y0 + hf0 +
2!
∂ x dt
�
t=t0
�
��
�
= F0 y0
First Order Method
Second Order Method
x = x0 + hy0 + O(h2 )
x = x0 + hy0 + 12 h2 f0 + O(h3 )
y = y0 + hf0 + O(h2 )
y = y0 + hf0 + 21 h2 F0 y0 + O(h3 )
How to Avoid Calculating the Matrix F0
�
∂f ��
f(x0 + δx) = f0 +
δx + O[(δx)2 ]
∂x
�
t=t0
or for any constant p
�
∂f ��
hpy0 = f0 + hpF0 y0 + O(h2 )
f(x0 + hpy0 ) = f0 +
∂x �
t=t0
or
1
[f(x0 + hpy0 ) − f0 ] = hF0 y0 + O(h2 )
p
Hence, the second-order method is equivalent to
Choose p =
1
2
x = x0 + hy0 + 12 h2 f(x0 ) + O(h3 )
�
1
�
1
f(x0 ) + h f(x0 + hpy0 ) + O(h3 )
y = y0 + h
1 −
2p
2p
and note that f(x0 ) − f(x0 + hpy0 ) = O(h). Therefore, we have
x = x0 + hy0 + 12 h2 f(x0 + 12 hy0 ) + O(h3 )
y = y0 + hf(x0 + 12 hy0 ) + O(h3 )
with only one evaluation of the function f(x) for x = x0 + 12 hy0 .
16.346 Astrodynamics
Lecture 33
Formal Derivation of the Second-Order Method
Choose a, b, p so that
x = x0 + hy0 + 12 h2 α0 + O(h3 )
x = x0 + hy0 + h2 ak + O(h3 )
≡
y = y0 + hbk + O(h3 )
k = f(x0 + hpy0 )
y = y0 + h(α0 + 12 hα1 ) + O(h3 )
k = α0 + hpα1 + O(h2 )
α 0 = f0 and α 1 = f0 = F0 y0 .
Expand f(x0 + hpy0 ) in a Taylor series:
�
∂f
��
f(x + δx) = f0 +
�
δx + O[(δx)2 ] =⇒
∂x
t=t0
where
Then
x = x0 + hy0 + h2 a(α0 + hpα1 ) + O(h3 )
�
∂f ��
f(x0 + hpy0 ) = f0 +
hpy0 +O(h2 )
�
∂x
t=t0
�
��
�
= α 0 + hp α 1
x = x0 + hy0 + 12 h2 α0 + O(h3 )
≡
y = y0 + hb(α0 + hpα1 ) + O(h3 )
Equate corresponding coefficients of α 0 and α 1
� �
� �
1
1
1
a= 2
=⇒
b= 1
p
2
y = y0 + h(α0 + 21 hα1 ) + O(h3 )
a=p=
1
2
b=1
In summary:
x = x0 + hy0 + 21 h2 k + O(h3 )
y = y0 + hk + O(h3 )
k = f(x0 + 12 hy0 )
Taylor Expansion using Indicial Notation and Summation Convention
h3 d3 xi
h4 d4 xi
h2 d2 xi
dxi
+
+
+
+ ···
dt
2! dt2
3! dt3
4! dt4
h2
h3 df i
h4 d2 f i
+
+ ···
= xi + hy i + f i +
2!
3! dt
4! dt2
3
3
h2
h3 � ∂f i dxj
h4 � d
�
∂f i dxj �
+
+
· · · = xi
+ hy i + f i +
2!
3!
j=1 ∂xj dt
4!
j=1 dt
∂xj dt
xi (t + h) = xi + h
= xi + hy i +
h2 i h3 i j h4 i j k
f + fj y + (fjk y y + fji f j ) + · · ·
2!
3!
4!
Taylor Expansion of a Vector Function of a Vector
f i (xi + δ i ) = f i + fji δ j +
16.346 Astrodynamics
1
2
i j k
fjk
δ δ +
Lecture 33
1
6
i
fjk
δj δk δ + · · ·
Nyström’s Third Order Method
Evert Johannes Nyström 1925
x = x0 + hy0 + h2 (a0 k0 + a1 k1 ) + O(h4 )
y=
y0 + h (b0 k0 + b1 k1 ) + O(h4 )
k0 = f(x0 + hp0 y0 )
k1 = f(x0 + hp1 y0 + h2 q1 k0 )
Series Expansion Using Indicial Notation
xi (t + h) = xi + hy i + 12 h2 f i + 16 h3 fji y j + O(h4 )
i j k
y i (t + h) = y i + hf i + 21 h2 fji y j + 61 h3 (fjk
y y + fji f j ) + O(h4 )
i
k0i = f i (xi + hp0 y i ) = f i + fji hp0 y j + 12 fjk
(hp0 y j )(hp0 y k ) + O(h3 )
� �� �
δ0i
k1i = f i (xi + hp1 y i + h2 q1 k0i ) = f i [xi + hp1 y i + h2 q1 f i + O(h3 )]
�
��
�
i
i
δ1
(hp1 y j )(hp1 y k ) + O(h3 )
= f i + fji (hp1 y j + h2 q1 f j ) + 1 fjk
2
Series Expansion Using Vector Notation
x = x0 + hy0 + h2 ( 12 α0 + 16 hα1 ) + O(h4 )
y = y0 + h[α0 + 12 hα1 + 16 h2 (α2 + β 2 )] + O(h4 )
k0 = f(x0 + hp0 y0 ) = α0 + hp0 α1 + 12 h2 p20 α2 + O(h3 )
k1 = f(x0 + hp1 y0 + h2 q1 k0 ) = α0 + hp1 α1 + h2 ( 12 p21 α2 + q1 β 2 ) + O(h3 )
Determine a0 , a1 , b0 , b1 , p0 , p1 , q1
h2 (a0 k0 + a1 k1 ) ≡ h2 ( 12 α0 + 16 hα1 )
to terms of order h3
h(b0 k0 + b1 k1 ) ≡ h[α0 + 12 hα1 + 16 h2 (α2 + β 2 )] to terms of order h3
Condition Equations
�
( α)
1
p0
1
p1
��
a0
a1
�
�1�
=
2
1
6
⎡
1
⎣ p0
p20
q 1 b1 =
(β )
16.346 Astrodynamics
⎤� �
⎡ ⎤
1
1
b0
p1 ⎦ b1 = ⎣ 12 ⎦
1
p21
3
Lecture 33
1
2
( 13 )
Solving the Condition Equations
First
b0 + b1 = 1
p0 b0 + p1 b1 = 12
p20 b0
+
p21 b1
=
(1 − p0 )b0 + (1 − p1 )b1 =
p0 (1 − p0 )b0 + p1 (1 − p1 )b1 =
=⇒
1
3
Hence
a0 = (1 − p0 )b0
Next, for consistency,
and
⇐⇒
a0 + a1 =
p0 a0 + p1 a1 =
1
2
1
6
a1 = (1 − p1 )b1 .
�
�1
�
�
D3 = � p0
�
�
p
2
0
b0 + b 1 = 1 p0 b0 + p1 b1 = 12
⇐⇒
p
20 b0 + p21 b1 =
1
2
1
6
1
3
1
p1
p
21
�
1
��
1 �
2 �� = 0 1 �
3
Expand the determinant
�
�
� 1 1 1
� Vandermonde determinant
�
�
�
��
�
�
�
D3 = � p0 p1 12 � =
(p1 − p0 ) [ 13 − 12 (p0 + p1 ) + p0 p1 ] = V2 L3 (p0 , p1 )
�
� 2
� ��
�
��
�
�
�
p
p
2 1 �
0
1
=0
3
Constraint function
Complete solution
− p1
b0 =
p0 − p1
1
2
b1 =
− p0
p1 − p 0
1
2
q1 =
1 p1 − p0
6 12 − p0
a0 = (1 − p0 )b0
a1 = (1 − p1 )b1
with p0 and p1 chosen arbitrarily subject to
L3 (p0 , p1 ) =
1
3
−
1
2
(p0 + p1 ) + p0 p1 = 0
Nyström’s Third Order Algorithm with p0 = 0
x = x0 + hy0 + 41 h2 (k0 + k1 ) + O(h4 )
y = y0 + 14 h(k0 + 3k1 ) + O(h4 )
k0 = f(x0 )
k1 = f(x0 + 23 hy0 + 29 h2 k0 )
Note: In the book Discrete Variable Methods in Ordinary Differential Equations by Peter
Henrici published by John Wiley & Sons, Inc. in 1962, there is a mistake. In his book,
Henrici didn’t derive the algorithm. He simply stated it. The factor 29 was erroneously
written as 13 . This error would be difficult to find since the algorithm would not exhibit
any particular problem. It just would not be as accurate as it should be.
The moral is
Never copy somebody’s algorithm!!
16.346 Astrodynamics
Lecture 33
Always derive it for yourself.
Nyström’s Fourth Order Algorithm
Used in the Apollo Guidance Computer
x = x0 + hy0 + 61 h2 (k0 + 2k1 ) + O(h5 )
y = y0 + 16 h(k0 + 4k1 + k2 ) + O(h5 )
where
k0 = f (t0 , x0 )
k1 = f (t0 + 12 h, x0 + 12 hy0 + 18 h2 k0 )
k2 = f (t0 + h, x0 + hy0 + 12 h2 k1 )
Nyström’s Fifth Order Algorithm
x = x0 + hy0 +
y = y0 +
+ 75k1 − 27k2 + 25k3 ) + O(h6 )
2
1
192 h (23k0
1
192 h(23k0
+ 125k1 − 81k2 + 125k3 ) + O(h6 )
where
k0 = f (t0 , x0 )
k1 = f (t0 + 25 h, x0 + 52 hy0 +
k2 = f (t0 + 32 h, x0 + 32 hy0 +
k3 = f [t0 + 45 h, x0 + 54 hy0 +
2 2
25 h k0 )
2 2
9 h k0 )
4 2
25 h (k0 +
k1 )]
R-K-N Sixth Order Algorithm
x = x0 + hy0 +
y = y0 +
1 2
90 h (7k0
1
90 h(7k0
+ 24k1 + 6k2 + 8k3 ) + O(h7 )
+ 32k1 + 12k2 + 32k3 + 7k4 ) + O(h7 )
where
k0 = f (t0 , x0 )
k1 = f (t0 + 41 h, x0 + 41 hy0 +
k2 = f [t0 +
k3 = f [t0 +
k4 = f [t0 +
16.346 Astrodynamics
1 2
32 h k0 )
1
1
1 2
2 h, x0 + 2 hy0 − 24 h (k0 − 4k1 )]
3
3
1 2
4 h, x0 + 4 hy0 + 32 h (3k0 + 4k1 + 2k2 )]
1 2
h, x0 + hy0 + 14
h (6k1 − k2 + 2k3 )]
Lecture 33
Download