From differential to difference equations for first order ODEs

When constructing an algorithm for the numerical integration of a differential equation, one should first convert the known ordinary differential equation (ODE) into an ordinary difference equation (OAE). Given this difference equation, one can then develop an appropriate numerical algorithm. This technical note describes the derivation of two such OAEs applicable to a first order ODE. The implicit OAE has the same asymptotic expansion as the ODE itself; whereas, the explicit OAE has an asymptotic expansion that is similar in structure but different in value when compared with that of the ODE. Many physical processes can be represented by systems of first order ODEs of the form or equivalently as 3ro JC_ + P_X_ = Q_ (for a = 1,2,.,N), (1) = Q_[X_,t]-Pa[X_,t]Xa (fora,/3= 1,2,.,N), (2) where the X_ are the N independent variables to be solved for, which may be scalar, vector or tensor valued in applications. The parameters P_ (a scalar), and F_ and Qo (of the same rank/type as X_), are functions of the variables XZ and t, in general. If neither P_ or Q_ depends on X_ for all a, fl, then the system of equations is said to be linear; otherwise, it is nonlinear. The dot '" is used to denote differentiation with respect to time, t. We choose time to be the dependent variable for illustrative purposes, as it so often is in physical applications; however, this is not a necessary restriction on the theory presented herein. *A technical note prepared for the Journal o. [ Computational Physics. The ODE of equations (1) and (2) is a point function in time. Numerical integration algorithms, however, are based on functions evaluated over an interval in time. We therefore introduce the first order OAE AX_ At J:o[X_,At,r], (3) where and therefore AX. = X. [t+At]Xo[t], (4) obtain the recursive integral equation [1] X_,[t+At] = exp a_=t + J(=t exp P_ [X_, (] d(] X_ [t] e [xe,(ld( a(, J(=( (6) which is an exact solution to this first order ODE. John Bernoulli [2] developed a nonrecursive solution similar to (6) in 1697 for the equation )( = aX + bX n, whose solution was sought by Jacob Bernoulli [3] in 1695. John's solution was expressed as a quadrature because the integral of dz/z in the form of a logarithm was not generally known until later that same year [4]. The authors have obtained a variety of approximate and exact solutions to (6) by representing the parameters P_ and Q_ with series expansions, and integrating them term by term. The resulting linear approximation, which was acquired by using Taylor series expansions, is given by [1] This approximation becomes exact whenever P_ and Q_ are both constants, i.e. whenever the ODE is linear. Rearranging the recursive solution (7) into a difference equation, one obtains two new relationships; they are, for the implicit case, (1--e-P_[X_'t+At]'At_ (P_[Xz,t+Atl.AX_ F_[X_,t+ :_[Xz,At, t+At] = -p--[_Z,t+At_.At .] + At]) o[ o q [x ,t+At] + O(t_At) _',_ ' (8) x. [t + At] = x. [t] + Tl. /,,t. (5) The OAE represents the ODE in numerical integration algorithms. The formulation is implicit when v = t + At; whereas, it is explicit when r = t. The development of existing algorithms begins with the tacit assumption that . _'_ = F_. We shall now show that this assumption is in error. This is accomplished by analytically integrating the ODE of (1) in a recursive manner, which permits the difference function 9:"a in (3) to be determined for the OAE. One can introduce an integrating factor into the differential equation (1) and thereby andfor the explicit case, &Ex ,At, tl= (1_ e-PotX.J , -fi__ / F_[XI_'t] +0 o q.[xz, t] t] (9) Notice the presence of an extra AXa term in the implicit relation (8), which acts as a correction to the derivative F_, and which is not present in the explicit relation (9). The coefficient (1 e-P_[X_'@/'t)/P,_[X_, r]. At is a correction factor of the first order that results from taking the differential function F_ at time v and converting it into a difference function . _'_ at time v taken over the interval (t, t+At). (Higher order solutions for the difference function .T'_ will be given in a future paper.) This coefficient goes to 1 in the limit as At goes to 0, as it must so as to recover the differential; in other words, lim . %'_[Xz, At, r] = F_[Xz, T] At ---*0 (lo) for both the implicit and explicit cases. A note of caution when writing computer code. In the neighborhood of P_[Xz, r]. At _ 0, one needs to expand (1e-P°[X_'_]'At)/P_,[X_, "*']. At into a power series to secure a sound computational algorithm. The presence of the coefficient (1e-P_[Xt_'r]'At)/Po[Xz, r]. At also introduces desirable asymptotic characteristics into our numerical approximations. In particular, for the implicit case where r = t + At, the asymptotic expansion for the OAE (3 with 8) is given by Q_[X_,t+At] lim X. [t+At]× (11) _t_l_g¢ P_ [X_, t + At] ' P_>O which is also the asymptotic expansion of the ODE (1 & 2). In contrast, for the explicit case where r = t, the asymptotic expansion for the OAE (3 with 9) is given by lim X_[t+At] _ Q_[Xe't] P_>O (12) These two asymptotic expansions differ only in when their parameters P_ and Qa are evaluated. For large time steps, the implicit case is asymptotically accurate and stable for exponentially decaying solutions, i.e. when P_[X_, t] > 0 V t. Stability becomes an issue only when P_ < 0. In constrast, the explicit case will oscillate around the true solution for large time steps, but with much less potential of becoming unbounded when compared with equivalent algorithms constructed without our correction coefficient. These oscillations can be mitigated only by choosing smaller time steps. The second integral in (6) is a Laplace [5] integral where the integrand has its largest value at the upper limit, t+At, and possesses an evanescent memory of the forcing function, Q_[Xz,{], provided that P_[Xz, _] > 0 over the interval (t, t+At). This fading memory means that the solution will depend mainly on the recent values of the forcing function, and that by concentrating the accuracy on the recent past we obtain accurate asymptotic representations of the solution. In the implicit solution, the integrands in (6) were expanded in Taylor series about their upper limits [1], where each integrand has its largest value and contributes the most to the