ordinary differential equations ii - computer...
TRANSCRIPT
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Ordinary Differential Equations II
CS 205A:Mathematical Methods for Robotics, Vision, and Graphics
Justin Solomon
CS 205A: Mathematical Methods Ordinary Differential Equations II 1 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Almost Done!
Last lecture on Wednesday!
I Homework 7: 6/3 (late days OK)
I Optional coding: 6/3 (no late days)
I Final exam review: 6/5(if someone attends)
I Final exam: 6/8, 12:15pm-3:15pm(Hewlett 201; confirm make-up)
CS 205A: Mathematical Methods Ordinary Differential Equations II 2 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Study Tips
I PracticeEspecially on modeling problems!
I Do sanity checksCome up with a function and minimize it. Factor a matrix.
I Implement and experiment
I IterateLook at solution, put it away, and try again.
I Time your practices
I Ask lots of questions!
CS 205A: Mathematical Methods Ordinary Differential Equations II 3 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Initial Value Problems
Find f (t) : R→ Rn
Satisfying F [t, f (t), f ′(t), f ′′(t), . . . , f (k)(t)] = 0
Given f (0), f ′(0), f ′′(0), . . . , f (k−1)(0)
CS 205A: Mathematical Methods Ordinary Differential Equations II 4 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Most Famous Example
~F = m~aNewton’s second law
CS 205A: Mathematical Methods Ordinary Differential Equations II 5 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Reasonable Assumption
Explicit ODEAn ODE is explicit if can be written in the form
f (k)(t) = F [t, f (t), f ′(t), f ′′(t), . . . , f (k−1)(t)].
CS 205A: Mathematical Methods Ordinary Differential Equations II 6 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
After Reduction
d~y
dt= F [~y]
CS 205A: Mathematical Methods Ordinary Differential Equations II 7 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Forward Euler
~yk+1 = ~yk + hF [~yk]
I Explicit method
I O(h2) localized truncation error
I O(h) global truncation error;
“first order accurate”
CS 205A: Mathematical Methods Ordinary Differential Equations II 8 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Backward Euler
~yk+1 = ~yk + hF [~yk+1]
I Implicit method
I O(h2) localized truncation error
I O(h) global truncation error;
“first order accurate”
CS 205A: Mathematical Methods Ordinary Differential Equations II 9 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Trapezoid Method
~yk+1 = ~yk + hF [~yk] + F [~yk+1]
2I Implicit method
I O(h3) localized truncation error
I O(h2) global truncation error;
“second order accurate”
CS 205A: Mathematical Methods Ordinary Differential Equations II 10 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Example
~y′ = A~y
−→ ~yk+1 =
(In×n −
hA
2
)−1(In×n +
hA
2
)~yk
CS 205A: Mathematical Methods Ordinary Differential Equations II 11 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Example
~y′ = A~y
−→ ~yk+1 =
(In×n −
hA
2
)−1(In×n +
hA
2
)~yk
CS 205A: Mathematical Methods Ordinary Differential Equations II 11 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Model Equation
y′ = ay, a < 0 −→ yk+1 = yk + hayk + ayk+1
2
yk =
(1 + 1
2ha
1− 12ha
)ky0
Unconditionally stable!
But this has nothing to do with accuracy.
CS 205A: Mathematical Methods Ordinary Differential Equations II 12 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Model Equation
y′ = ay, a < 0 −→ yk+1 = yk + hayk + ayk+1
2
yk =
(1 + 1
2ha
1− 12ha
)ky0
Unconditionally stable!
But this has nothing to do with accuracy.
CS 205A: Mathematical Methods Ordinary Differential Equations II 12 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Model Equation
y′ = ay, a < 0 −→ yk+1 = yk + hayk + ayk+1
2
yk =
(1 + 1
2ha
1− 12ha
)ky0
Unconditionally stable!
But this has nothing to do with accuracy.
CS 205A: Mathematical Methods Ordinary Differential Equations II 12 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Model Equation
y′ = ay, a < 0 −→ yk+1 = yk + hayk + ayk+1
2
yk =
(1 + 1
2ha
1− 12ha
)ky0
Unconditionally stable!
But this has nothing to do with accuracy.
CS 205A: Mathematical Methods Ordinary Differential Equations II 12 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Model Equation
y′ = ay, a < 0 −→ yk+1 = yk + hayk + ayk+1
2
yk =
(1 + 1
2ha
1− 12ha
)ky0
Unconditionally stable!
But this has nothing to do with accuracy.
CS 205A: Mathematical Methods Ordinary Differential Equations II 12 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Is Stability Useful Here?
R =yk+1yk
Oscillatory behavior!
CS 205A: Mathematical Methods Ordinary Differential Equations II 13 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Is Stability Useful Here?
R =yk+1yk
Oscillatory behavior!
CS 205A: Mathematical Methods Ordinary Differential Equations II 13 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Example
Useful for mid-size time steps
CS 205A: Mathematical Methods Ordinary Differential Equations II 14 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Pattern
Convergence as h→ 0 is not the whole story nor
is stability. Often should consider behavior
for fixed h > 0.
Qualitative and quantitative analysis needed!
CS 205A: Mathematical Methods Ordinary Differential Equations II 15 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Pattern
Convergence as h→ 0 is not the whole story nor
is stability. Often should consider behavior
for fixed h > 0.
Qualitative and quantitative analysis needed!
CS 205A: Mathematical Methods Ordinary Differential Equations II 15 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Observation
~yk+1 = ~yk+
∫ tk+h
tk
F [~y(t)] dt
CS 205A: Mathematical Methods Ordinary Differential Equations II 16 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Alternative Derivation ofTrapezoid Method
~yk+1 = ~yk +h
2(F [~yk] + F [~yk+1]) +O(h3)
Implicit method
CS 205A: Mathematical Methods Ordinary Differential Equations II 17 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Heun’s Method
~yk+1 = ~yk +h
2(F [~yk] + F [~yk + hF [~yk]]) +O(h3)
Replace implicit part with lower-order integrator!
CS 205A: Mathematical Methods Ordinary Differential Equations II 18 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Stability of Heun’s Method
y′ = ay, a < 0
yk+1 =
(1 + ha +
1
2h2a2
)yk
=⇒ h <2
|a|
Forward Euler: h < 2|a|
CS 205A: Mathematical Methods Ordinary Differential Equations II 19 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Stability of Heun’s Method
y′ = ay, a < 0
yk+1 =
(1 + ha +
1
2h2a2
)yk
=⇒ h <2
|a|
Forward Euler: h < 2|a|
CS 205A: Mathematical Methods Ordinary Differential Equations II 19 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Stability of Heun’s Method
y′ = ay, a < 0
yk+1 =
(1 + ha +
1
2h2a2
)yk
=⇒ h <2
|a|
Forward Euler: h < 2|a|
CS 205A: Mathematical Methods Ordinary Differential Equations II 19 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Runge-Kutta Methods
Apply quadrature to:
~yk+1 = ~yk +
∫ tk+1
tk
F [~y(t)] dt
Use low-order integrators
CS 205A: Mathematical Methods Ordinary Differential Equations II 20 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Runge-Kutta Methods
Apply quadrature to:
~yk+1 = ~yk +
∫ tk+1
tk
F [~y(t)] dt
Use low-order integrators
CS 205A: Mathematical Methods Ordinary Differential Equations II 20 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
RK4: Simpson’s Rule
~yk+1 = ~yk +h
6(~k1 + 2~k2 + 2~k3 + ~k4)
where ~k1 = F [~yk]
~k2 = F
[~yk +
1
2h~k1
]~k3 = F
[~yk +
1
2h~k2
]~k4 = F
[~yk + h~k3
]CS 205A: Mathematical Methods Ordinary Differential Equations II 21 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Using the Model Equation
~y′ ≈ A~y
=⇒ ~y(t) ≈ eAt~y0
CS 205A: Mathematical Methods Ordinary Differential Equations II 22 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Exponential Integrators
~y′ = A~y +G[~y]
First-order exponential integrator:
~yk+1 = eAh~yk + A−1(eAh − In×n)G[~yk]
CS 205A: Mathematical Methods Ordinary Differential Equations II 23 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Exponential Integrators
~y′ = A~y +G[~y]
First-order exponential integrator:
~yk+1 = eAh~yk + A−1(eAh − In×n)G[~yk]
CS 205A: Mathematical Methods Ordinary Differential Equations II 23 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Returning to Our Reduction
~y′(t) = ~v(t)
~v′(t) = ~a(t)
~a(t) = F [t, ~y(t), ~v(t)]
~y(tk + h) = ~y(tk) + h~y′(tk) +h2
2~y′′(tk) +O(h3)
Don’t need high-order estimators for derivatives.
CS 205A: Mathematical Methods Ordinary Differential Equations II 24 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Returning to Our Reduction
~y′(t) = ~v(t)
~v′(t) = ~a(t)
~a(t) = F [t, ~y(t), ~v(t)]
~y(tk + h) = ~y(tk) + h~y′(tk) +h2
2~y′′(tk) +O(h3)
Don’t need high-order estimators for derivatives.
CS 205A: Mathematical Methods Ordinary Differential Equations II 24 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
New Formulae
~vk+1 = ~vk +
∫ tk+1
tk
~a(t) dt
~yk+1 = ~yk + h~vk +
∫ tk+1
tk
(tk+1 − t)~a(t) dt
~a(τ) = (1− γ)~ak + γ~ak+1+~a′(τ)(τ −hγ− tk)+O(h2)
for τ ∈ [a, b]
CS 205A: Mathematical Methods Ordinary Differential Equations II 25 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
New Formulae
~vk+1 = ~vk +
∫ tk+1
tk
~a(t) dt
~yk+1 = ~yk + h~vk +
∫ tk+1
tk
(tk+1 − t)~a(t) dt
~a(τ) = (1− γ)~ak + γ~ak+1+~a′(τ)(τ −hγ− tk)+O(h2)
for τ ∈ [a, b]
CS 205A: Mathematical Methods Ordinary Differential Equations II 25 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
New Formulae
~vk+1 = ~vk +
∫ tk+1
tk
~a(t) dt
~yk+1 = ~yk + h~vk +
∫ tk+1
tk
(tk+1 − t)~a(t) dt
~a(τ) = (1− γ)~ak + γ~ak+1+~a′(τ)(τ −hγ− tk)+O(h2)
for τ ∈ [a, b]
CS 205A: Mathematical Methods Ordinary Differential Equations II 25 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Newmark Class
~yk+1 = ~yk + h~vk +
(1
2− β
)h2~ak + βh2~ak+1
~vk+1 = ~vk + (1− γ)h~ak + γh~ak+1
~ak = F [tk, ~yk, ~vk]
Parameters: β, γ (can be implicit or explicit!)
CS 205A: Mathematical Methods Ordinary Differential Equations II 26 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Newmark Class
~yk+1 = ~yk + h~vk +
(1
2− β
)h2~ak + βh2~ak+1
~vk+1 = ~vk + (1− γ)h~ak + γh~ak+1
~ak = F [tk, ~yk, ~vk]
Parameters: β, γ (can be implicit or explicit!)
CS 205A: Mathematical Methods Ordinary Differential Equations II 26 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Constant Acceleration: β = γ = 0
~yk+1 = ~yk + h~vk +1
2h2~ak
~vk+1 = ~vk + h~ak
Explicit, exact for constant acceleration, linear
accuracy
CS 205A: Mathematical Methods Ordinary Differential Equations II 27 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Constant Implicit Acceleration:β = 1/2, γ = 1
~yk+1 = ~yk + h~vk +1
2h2~ak+1
~vk+1 = ~vk + h~ak+1
Backward Euler for velocity, midpoint for
position; globally first-order accurate
CS 205A: Mathematical Methods Ordinary Differential Equations II 28 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Trapezoid: β = 1/4, γ = 1/2
~xk+1 = ~xk +1
2h(~vk + ~vk+1)
~vk+1 = ~vk +1
2h(~ak + ~ak+1)
Trapezoid for position and velocity; globally
second-order accurate
CS 205A: Mathematical Methods Ordinary Differential Equations II 29 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Central Differencing: β = 0, γ = 1/2
~vk+1 =~yk+2 − ~yk
2h
~ak+1 =~yk+1 − 2~yk+1 + ~yk
h2
Central difference for position and velocity;
globally second-order accurate
CS 205A: Mathematical Methods Ordinary Differential Equations II 30 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Newmark Schemes
I Generalizes large class of integrators
I Second-order accuracy (exactly) when
γ = 1/2
I Unconditional stability when 4β > 2γ > 1
(otherwise radius is function of β, γ)
CS 205A: Mathematical Methods Ordinary Differential Equations II 31 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Staggered Grid
~yk+1 = ~yk + h~vk+1/2
~vk+3/2 = ~vk+1/2 + h~ak+1
~ak+1 = F
[tk+1, ~xk+1,
1
2(~vk+1/2 + ~vk+3/2)
]
Leapfrog: ~a not a function of ~v; explicit
Otherwise: Symmetry in ~v dependence
CS 205A: Mathematical Methods Ordinary Differential Equations II 32 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Staggered Grid
~yk+1 = ~yk + h~vk+1/2
~vk+3/2 = ~vk+1/2 + h~ak+1
~ak+1 = F
[tk+1, ~xk+1,
1
2(~vk+1/2 + ~vk+3/2)
]Leapfrog: ~a not a function of ~v; explicit
Otherwise: Symmetry in ~v dependence
CS 205A: Mathematical Methods Ordinary Differential Equations II 32 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Staggered Grid
~yk+1 = ~yk + h~vk+1/2
~vk+3/2 = ~vk+1/2 + h~ak+1
~ak+1 = F
[tk+1, ~xk+1,
1
2(~vk+1/2 + ~vk+3/2)
]Leapfrog: ~a not a function of ~v; explicit
Otherwise: Symmetry in ~v dependence
CS 205A: Mathematical Methods Ordinary Differential Equations II 32 / 33
Reminders Review Trapezoid Runge-Kutta Exponential Integrators Multivalue Methods
Leapfrog Integration
+t
~y0 ~y1 ~y2 ~y3 ~y4
~a0 ~a1 ~a2 ~a3 ~a4
~v1/2 ~v3/2 ~v5/2 ~v7/2~v0
Next
CS 205A: Mathematical Methods Ordinary Differential Equations II 33 / 33