216
8 Solving Ordinary Differential Equations
or with f (u, t) = ru in our special model problem for population growth,
u n+1 − u n
Δt
= ru
n .
(8.4)
If r depends on time, we insert r(t n ) = r n for r in this latter equation.
The fourth step is to derive a computational algorithm. Looking at (8.3), we
realize that if u n should be known, we can easily solve with respect to u n+1 to
get a formula for u at the next time level t n+1 :
u
n+1
= u
n
+ Δtf (u
n , t n ) .
(8.5)
Provided we have a known starting value, u 0 = U 0 , we can use (8.5) to advance the
solution by first computing u 1 from u 0 , then u 2 from u 1 , u 3 from u 2 , and so forth.
Such an algorithm is called a numerical scheme for the differential equation. It is
often written compactly as
u
n+1
= u
n
+ Δtf (u
n , t n ), u
0
= U 0 , n = 0, 1, . . . , N t − 1 .
(8.6)
This scheme is known as the Forward Euler scheme, also called Euler’s method.
In our special population growth model, we have
u
n+1
= u
n
+ Δt ru
n , u
0
= U 0 , n = 0, 1, . . . , N t − 1 .
(8.7)
We may also write this model using the problem-specific symbol N instead of the
generic u function:
N
n+1
= N
n
+ Δt rN
n , N
0
= N 0 , n = 0, 1, . . . , N t − 1 .
(8.8)
The observant reader will realize that (8.8) is nothing but the computational
model (8.2) arising directly in the model derivation. The formula (8.8) arises,
however, from a detour via a differential equation and a numerical method for the
differential equation. This looks rather unnecessary! The reason why we bother to
derive the differential equation model and then discretize it by a numerical method is
simply that the discretization can be done in many ways, and we can create (much)
more accurate and more computationally efficient methods than (8.8) or (8.6). This
can be useful in many problems! Nevertheless, the Forward Euler scheme is intuitive
and widely applicable, at least when Δt is chosen to be small.
The numerical solution between the mesh points
Our numerical method computes the unknown function u at discrete mesh
points t 1 , t 2 , . . . , t N t . What if we want to evaluate the numerical solution
between the mesh points? The most natural choice is to assume a linear
variation between the mesh points, see Fig. 8.5. This is compatible with the
fact that when we plot the array u 0 , u 1 , . . . versus t 0 , t 1 , . . ., a straight line is
automatically drawn between the discrete points (unless we specify otherwise
in the plot command).
Précédent

- 236/350

Suivant