Numerical Solutions to ODEs Nancy Griffeth January 14, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex Systems,” an NSF Expedition in Computing (Award Number ).
ODE Numerical Differentiation Definition of Differentiation Problem: We do not have an infinitesimal h Solution: Use a small h as an approximation 2
ODE Forward Difference & Backward Difference Forward Difference Backward Difference 3
ODE Numerical Differentiation - Example Compute the derivative of function At point x=1.15 4
Euler Method Explicit Euler Method Consider Forward Difference Which implies 5
Euler Method Explicit Euler Method Split time t into n slices of equal length Δt The Explicit Euler Method Formula 6
Euler Method Explicit Euler Method - Algorithm 7
Euler Method Implicit Euler Method Consider Backward Difference Which implies 8
Euler Method Implicit Euler Method Split the time into slices of equal length The above differential equation should be solved to get the value of y(t i+1 ) Extra computation Sometimes worth because implicit method is more accurate 9
Euler Method A Simple Example Try to solve IVP What is the value of y when t=0.5? The analytical solution is 10
Using explicit Euler method We choose different dts to compare the accuracy 11 Euler Method A Simple Example
texactdt=0.05errordt=0.025errordt= error At some given time t, error is proportional to dt. Euler Method A Simple Example
For some equations called Stiff Equations, Euler method requires an extremely small dt to make result accuracy The Explicit Euler Method Formula The choice of Δt matters! 13 Euler Method A Simple Example
Assume k=5 Analytical Solution is Try Explicit Euler Method with different dts 14 Euler Method A Simple Example
Choose dt=0.002, s.t. Works! 15
Choose dt=0.25, s.t. Oscillates, but works. 16
Choose dt=0.5, s.t. Instability! 17
Euler Method Stiff Equation – Explicit Euler Method For large dt, explicit Euler Method does not guarantee an accurate result 18 texactdt=0.5errordt=0.25errordt=0.002error
Euler Method Stiff Equation – Implicit Euler Method Implicit Euler Method Formula Which implies 19
Choose dt=0.5, Oscillation eliminated! Not elegant, but works. 20