Some ODEs are hard (or impossible!) to solve analytically... or maybe you just
don’t want to! Numerical approximations to the solution can be very valuable in
these cases.
For example, let’s solve the initial value problem:
Comparing the numerical and analytical solutions at the same time points by
computing the absolute error between them gives:
t
Numerical
Analytical
Error
0
0
0
0
0.2
0
0.021
0.021
0.4
0.04
0.092
0.052
0.6
0.128
0.222
0.094
0.8
0.274
0.426
0.152
1.0
0.489
0.718
0.229
The error increases as more timesteps are run due to accumulation of error. A
smaller timestep typically produces a better solution, but at the cost of doing
additional calculations. We will discuss next how the error depends on the step
size.
Because we are using truncated Taylor series, we accrue an error:
The error in a single step is O(Δt2). This is called the local error.
To cover a finite time t, t/Δt steps are required so the global
(total) error is O(Δt). To improve accuracy, you should decrease Δt, but this takes more work. Some Δt will also totally fail! This is
the field of numerical stability (not covered here).
The absolute error is 0.369 for Δt=0.1 and 0.730 for Δt=0.2.
Hence the error decreases by about a factor of 2 when Δt is also
decreased by a factor of 2.