High accuracy needs small steps:
But if accuracy is not important, can we take large steps?
Example:
| step | time (s) | c |
| 0 | 0.0 | 0.099000 |
| 1 | 900.0 | 0.102600 |
| 2 | 1800.0 | 0.093240 |
| 3 | 2700.0 | 0.117576 |
| 4 | 3600.0 | 0.054302 |
| 5 | 4500.0 | 0.218814 |
| 6 | 5400.0 | -0.208916 |
| 7 | 6300.0 | 0.903181 |
| 8 | 7200.0 | -1.988271 |
Numerical instability if time step is large.
Reason for the instability:
1 - hk negative if
oscillations;
1 - hk < -1 if
oscillations grow.
Approximate dx/dt by backward difference.
Implicit Euler (for first step):
Must be treated as an equation for x1. If f(x) is linear, solution is easy. If f(x) is non-linear, we have a NLAE; solution needs iteration.
Implicit Euler:
Does this overcome the problem of instability?
Always between one and zero for positive k.
Tends to zero at large k.
`Strongly A-stable' method.
| step | time (s) | Implicit Euler | exact | error |
| 0 | 0.0 | 0.099000 | 0.099000 | 0.000000 |
| 1 | 900.0 | 0.099783 | 0.099973 | 0.000190 |
| 2 | 1800.0 | 0.099953 | 0.099999 | 0.000047 |
| 3 | 2700.0 | 0.099990 | 0.100000 | 0.000010 |
| 4 | 3600.0 | 0.099998 | 0.100000 | 0.000002 |
| 5 | 4500.0 | 0.100000 | 0.100000 | 0.000000 |
| 6 | 5400.0 | 0.100000 | 0.100000 | 0.000000 |
| 7 | 6300.0 | 0.100000 | 0.100000 | 0.000000 |
| 8 | 7200.0 | 0.100000 | 0.100000 | 0.000000 |
Non-linear equation: solve a NLAE at each time step.
For
Choice of NLAE method:
For short time steps direct substitution may work well enough:
Newton's method is recommended. Use the value at xn as a starting guess for xn+1, i.e.
Algorithm is similar to explicit Euler except for the point within the time step loop where we calculate xn+1.
Specify initial conditions: t0 and x0.
Specify final time tf and
step size h.
Initialise step counter n = 0.Do while tn < tf
set tn+1 = tn + hend do
if tn+1 > tf thenset tn+1 = tfend if
redefine h = tf - tn
! THIS IS DIFFERENT:
solve
for xn+1.
increment n by 1return
Initialise
x(0) = xn.
Do k = 1,max_iterations
! max_iterations is maximum number of Newton iterations at each time step
call deriv_and_fnend do
(x(k-1),tn+1, f,dfdx)
! you must supply a subroutine
! deriv_and_fn (x,t,f,dfdx) which
! when given x and t will calculate
! and return
! f = f(x,t) and dfdx =![]()
calculate g = x(k-1) - xn - h f
if |g| <nlae_tolerance exit
calculate![]()
| step | time | M | iterations |
| 0 | 0.0 | 100.000 | 0 |
| 1 | 50.0 | 169.719 | 3 |
| 2 | 100.0 | 221.043 | 3 |
| 3 | 150.0 | 259.846 | 3 |
| 4 | 200.0 | 289.654 | 3 |
| 5 | 250.0 | 312.794 | 3 |
| 6 | 300.0 | 330.890 | 3 |
| 7 | 350.0 | 345.117 | 3 |
| 8 | 400.0 | 356.346 | 3 |
| 9 | 450.0 | 365.235 | 3 |
| 10 | 500.0 | 372.280 | 2 |
Total number of iterations 29
Implicit Euler uses backward difference and is always stable for problems which tend to a steady state, no matter how large the time step.
If the ODE is non-linear, then with implicit Euler we must solve a NLAE at each time step.
Newton's method will converge quickly in most cases, using x at the start of the step as a guess for the end of the step.
Next - Section 4.4.6: Systems of ODE's
Return to Section 4.4 Index
Return to Section 4 Index
Course Organiser Last modified: Wed Aug 5 10:35:12 BST