![Page 2: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/2.jpg)
2
Talk Summary
Going to talk about: Euler’s method subject to errors Implicit methods help, but complicated Verlet methods help, but velocity
inaccurate Symplectic methods can be good for
both
![Page 3: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/3.jpg)
3
Forces Encountered
Dependant on position: springs, orbits
Dependant on velocity: drag, friction Constant: gravity, thrust
Will consider how methods handle these
![Page 4: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/4.jpg)
4
Euler’s Method
Has problems Expects the derivative at the current
point is a good estimate of the derivative on the interval
Approximation can drift off the actual function – adds energy to system!
Worse farther from known values Especially bad when:
System oscillates (springs, orbits, pendulums) Time step gets large
![Page 5: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/5.jpg)
5
Euler’s Method (cont’d)
Example: orbiting object
x0 x1
x2
t
x
x4
x3
![Page 6: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/6.jpg)
6
Stiffness
Have similar problems with “stiff” equations Have terms with rapidly decaying values Larger decay = stiffer equation = req. smaller h
Often seen in equations with stiff springs (hence the name)
t
x
![Page 7: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/7.jpg)
7
Euler
Lousy for forces dependant on position
Okay for forces dependant on velocity
Bad for constant forces
![Page 8: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/8.jpg)
8
Runge-Kutta
Idea: single derivative bad estimate Use weighted average of derivatives
across interval How error-resistant indicates order Midpoint method Order Two Usually use Runge-Kutta Order Four,
or RK4
![Page 9: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/9.jpg)
9
Runge-Kutta (cont’d)
RK4 better fit, good for larger time steps
Tends to dampen energy Expensive – requires many
evaluations If function is known and fixed (like in
physical simulation) can reduce it to one big formula
![Page 10: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/10.jpg)
10
Runge-Kutta
Okay for forces dependant on position
Okay for forces dependant on velocity
Great for constant forces
But expensive: four evaluations of derivative
![Page 11: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/11.jpg)
11
Implicit Methods
Explicit Euler method adds energy Implicit Euler dampens it Use new velocity, not current E.g. Backwards Euler:
Better for stiff equations11
11
++
++
+=+=
iii
iii
hhvvv
xxx
&
&
![Page 12: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/12.jpg)
12
Implicit Methods
Result of backwards Euler Solution converges - not great But it doesn’t diverge!
x0
x1
x2x3
![Page 13: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/13.jpg)
13
Implicit Methods
How to compute or ? Derive from formula (most accurate) Solve using linear system (slowest, but
general) Compute using explicit method and plug
in value (predictor-corrector)
1+ix& 1+iv&
![Page 14: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/14.jpg)
14
Implicit Methods
Solving using linear system:
Resulting matrix is sparse, easy to invert
![Page 15: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/15.jpg)
15
Implicit Methods
Example of predictor-corrector:
mh
h
mh
h
iiiiii
iiii
iiii
iii
/)),()~,~((2/
)~(2/
/),(~
~
111
11
1
1
vxFvxFvv
vvxx
vxFvv
vxx
+⋅+=+⋅+=
⋅+=⋅+=
+++
++
+
+
![Page 16: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/16.jpg)
16
Backward Euler
Okay for forces dependant on position
Great for forces dependant on velocity
Bad for constant forces
But tends to converge: better but not ideal
![Page 17: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/17.jpg)
17
Verlet Integration
Velocity-less scheme From molecular dynamics Uses position from previous time step Very stable, but velocity estimated Good for particle systems, not rigid
bodyiiii h axxx ⋅+−= −+
211 2
![Page 18: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/18.jpg)
18
Verlet Integration
Leapfrog Verlet
Velocity Verlet
€
vi+1/ 2 = vi + hi /2 ⋅a ix i+1 = x i + h ⋅vi+1/ 2
vi+1 = vi+1/ 2 + hi /2 ⋅a i+1
€
vi+1/ 2 = vi−1/ 2 + hi ⋅a ix i+1 = x i + hi ⋅vi+1/ 2
![Page 19: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/19.jpg)
19
Verlet Integration
Better for forces dependant on position Okay for forces dependant on velocity Okay for constant forces
Not too bad, but still have estimated velocity problem
![Page 20: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/20.jpg)
20
Symplectic Euler
Idea: velocity and position are not independent variables
Make use of relationship Run Euler’s in reverse: compute
velocity first, then position Very stable
![Page 21: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/21.jpg)
21
Symplectic Euler
Applied to orbit example
(Admittedly this is a bit contrived)
x0 x1
x2
x3
![Page 22: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/22.jpg)
22
Symplectic Euler
Good for forces dependant on position Okay for forces dependant on velocity Bad for constant forces
But cheap and stable!
![Page 23: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/23.jpg)
23
Which To Use?
With simple forces, standard Euler or higher order RK might be okay
But constraints, springs, etc. require stability Recommendation: Symplectic Euler
Generally stable Simple to compute (just swap velocity and position
terms) More complex integrators available if you need them
-- see references
![Page 24: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/24.jpg)
24
References
Burden, Richard L. and J. Douglas Faires, Numerical Analysis, PWS Publishing Company, Boston, MA, 1993.
Witken, Andrew, David Baraff, Michael Kass, SIGGRAPH Course Notes, Physically Based Modelling, SIGGRAPH 2002.
Eberly, David, Game Physics, Morgan Kaufmann, 2003.
![Page 25: Numeric Integration Methods Jim Van Verth Red Storm Entertainment jimvv@redstorm.com](https://reader033.vdocuments.net/reader033/viewer/2022061306/5514664c550346284e8b5b55/html5/thumbnails/25.jpg)
25
References
Hairer, et al, “Geometric Numerical Integration Illustrated by the Störmer/Verlet method,” Acta Numerica (2003), pp 1-51.
Robert Bridson, Notes from CPSC 533d: Animation Physics, University of BC.