Ordinary differential equations Phys 420/580 Lecture 8
Most physical laws are expressed as differential equations These come in three flavours: initial-value problems boundary-value problems eigenvalue problems
Most physical laws are expressed as differential equations These come in three flavours: initial-value problems boundary-value problems eigenvalue problems first order x (t) =F (x(t),t) x(0) = x 0 second order x (t) =F (x(t),x (t),t) x(0) = x 0 x (0) = v 0
Most physical laws are expressed as differential equations These come in three flavours: x R : u (x) =F (u(x),u (x); x) initial-value problems boundary-value problems eigenvalue problems x R : u(x) =α(x) or u (x) =β(x)
Most physical laws are expressed as differential equations These come in three flavours: x R : u (x) =F (u(x),u (x); x; λ) initial-value problems boundary-value problems eigenvalue problems x R : u(x) =α(x) or u (x) =β(x) solutions only at specific eigenvalues
In principle, the initial value problem ODE can be forward integrated from its specified starting point dx dt = F (x(t),t) x(0) = x 0 x(t) =x 0 + t 0 dt F (x(t ),t ) Need to generate a numerical estimate of the integral on the rhs of the formal solution
As usual, we chop the real time variable into discrete time steps t = t i+1 t i x(t + t) =x(t)+ x(t i+1 )=x(t i )+ t+ t t ti+1 dt F (x(t ),t ) t i dt F (x(t ),t ) If t is sufficiently small, then the integral is wellapproximated by a low-order estimate of the area
missing weight Various first-order approximations: x i+1 = x i + F i t x i+1 = x i + 1 2 Fi + F i+1 t where in the future x i = x(t i ),F i = F (x(t i ),t i ) F(x(t),t) box rule t i t i+1 F(x(t),t) t The choices of box and trapezoid integration correspond to the socalled Euler and Picard methods t i t i+1 trapezoid rule t
Algorithm for the Euler method is very simple Accuracy of the method is low, and large errors accumulate over time Not necessarily energyconserving Set x 0 to its initial value Step through each t i (i 0): compute F i = F (x i,t i ) x i+1 = x i + F i t t i+1 = t i + t
Set x 0 to its initial value Picard method requires a selfconsistent solution Accurate but slow May not converge for too large a choice of time step Step through each t i (i 0): compute F i = F (x i,t i ) t i+1 = t i + t compute x (1) i+1 via Euler Loop over k =1, 2, 3,... compute F (k) i+1 = F (x(k) x (k+1) i+1 = x i + 1 2 i+1,t i+1) Fi + F (k) i+1 t Exit loop if x (k+1) i+1 x (k) i+1 < x i+1 = x (k max) i+1
Systematic expansion: replace dummy variable by and Taylor expand the integrand t = t + δt F (x(t + δt),t+ δt) =F (x(t),t)+ F x x (t)δt + F t Integration over 0 < δt < t x i+1 = x i + F i t + 1 F F i 2 x yields + F i t δt + O(δt)2 not necessarily available to us ( t) 2 + i Truncation at first order corresponds to the Euler method
According to the mean value theorem, an exact truncation is of the form x i+1 = x i + F (x(τ), τ) t, τ [t i,t i+1 ] F is evaluated at some intermediate point Ideal value of τ absorbs all curvature corrections Possibility of systematic improvements
Euler x i+1 E.g., second-order Runge-Kutta x i x i+1 = x i + F (x,t ) t t x = x i + 1 2 F (x i,t i ) t t i t i+1 t = t i + 1 2 t Runge-Kutta x* x i+1 local errors at O( t) 2 x i t i t* t i+1 t
Runge-Kutta Schemes Exact evolution over a small time step: x(t + t) =x(t)+ t 0 d(δt) F (x(t + δt),t+ δt) Expand both sides in a small time increment: x(t + t) =x(t)+x (t) t + 1 2 x (t)( t) 2 + 1 6 x (t)+ = x(t)+f t + 1 Ft + FF x ( t) 2 2 + 1 Ftt +2FF tx + F 6 2 F xx + FFx 2 + F t F x ( t) 3 + partial derivatives
Runge-Kutta Schemes Runge-Kutta ansatz at order m: x(t + t) =x(t)+α 1 c 1 + α 2 c 2 + + α m c m Function evaluation at many points in the interval c 1 =( t)f (x, t) c 2 =( t)f (x + ν 21 c 1,t+ ν 21 t) c 3 =( t)f (x + ν 31 c 1 + ν 32 c 2,t+(ν 31 + ν 32 ) t) c 4 =( t)f (x + ν 41 c 1 + ν 42 c 2 + ν 43 c 3,t+(ν 41 + ν 42 + ν 43 ) t). m equations and m + m(m 1)/2 unknowns {α i, ν ij }
Second-order ODEs We have discussed the Euler, Picard, and Runge-Kutta schemes for integrating the first-order initial value problem: x (t) =F (x(t),t) x(0) = x 0 Similar considerations can be applied to the second-order problem: x (t) =F (x(t),x (t),t) x(0) = x 0 x (0) = v 0
Second-order ODEs Convenient to reinterpret the second-order system as two coupled first-order equations x (t) =F (x(t),x (t),t) x(0) = x 0 x (0) = v 0 v (t) =A(x(t),v(t),t) x (t) =v(t) x(0) = x 0 v(0) = v 0 Obvious connection to classical mechanics: velocity v and acceleration model A
Second-order ODEs Naive generalization of Euler method to the pair of first order equations Some ambiguity in the labelling of time steps Set x 0 and v 0 to their initial values Step through each t i (i 0): compute a i = A(x i,v i,t i ) v i+1 = v i + a i t x i+1 = x i + v i t t i+1 = t i + t Could equally read v i+1 and still be correct to O( t) (Euler-Cromer)
Second-order ODEs Can achieve higher order algorithms systematically at the cost of having more time steps involved in each update x i+1 = x i + v i t + 1 2 a i( t) 2 + O( t) 3 x i 1 = x i v i t + 1 2 a i( t) 2 + O( t) 3 Adding and subtracting the forward and reverse forms x i+1 =2x i x i 1 + a i ( t) 2 v i = x i+1 x i 1 (Verlet method) t
Second-order ODEs Verlet method is more numerically stable than Euler It is not self-starting: it needs both and (x 0,v 0 ) (x 1,v 1 ) Accuracy can be arbitrarily improved in this way at the cost of more starting points: (x 2,v 2 ), etc. Fortunately, there is an update rule mathematically equivalent to Verlet that is self-starting: depends on x i+1 only x i+1 = x i + v i t + 1 2 a i( t) 2 v i+1 = v i + 1 2 (a i+1 + a i ) t (self-starting Verlet)
Second-order ODEs Runge-Kutta has the advantage of begin self-starting 4th order Runge-Kutta for Newton s equations of motion: k 1v = A(x i,v i,t i ) t k 1x = v i t k 2v = A(x i + 1 2 k 1x,v i + 1 2 k 1v,t i + 1 2 t) k 3v = A(x i + 1 2 k 2x,v i + 1 2 k 2v,t i + 1 2 t) k 3x = v i + 1 2 k 2v t k 4v = A(x i + k 3x,v i + k 3v,t i + t) k 4x = v i + k 3x t v i+1 = v i + 1 6 k1v +2k 2v +2k 3v + k 4v x i+1 = x i + 1 6 k1x +2k 2x +2k 3x + k 4x