# Explicit Versus Implicit Methods for Ordinary Differential Equations

We briefly illustrate the use of Euler and Backward Euler on the simple ODE x'(t) = -1000*x(t), where x(0) = 1. It is easy to confirm that the exact solution is x(t) = exp(-1000*t). A graph is shown below. This ODE is called stiff because the solution changes very quickly in one part of its domain (near 0) and slowly elsewhere.

Let h>0 be the stepsize, and t(i)=i*h. If we apply Euler's method with stepsize h>0, then we approximate the differential equation by the simpler equation (a straight line):

```     x( t+h ) ~ x( t ) - h*1000*x( t ) = (1-h*1000) * x(t)
```
We use this approximation to compute an approximate solution x(i) ~ x( t(i) ) by the analogous formula
```     x( i+1 ) = x( i ) - h*1000*x( i )
= (1-h*1000) * x( i )
= (1-h*1000)^i * x( 1 )   .
```
For the computed solution x(i) to approach 0 monotonically as does the exact solution x(t(i)), we need to choose h so that 0 < 1-h*1000 < 1, or 0 < h < 1/1000. In other words, we must take very short steps, even after x(t) is very small. For if we don't, for instance if h = .01 and so 1-h*1000 = -9, then the solution will grow in magnitude by a factor of 9 and oscillate from step to step, rather than decay to zero.

In contrast, suppose we apply Backward Euler with stepsize h. We get the approximation (a different straight line):

```     x( t+h ) ~ x( t ) - h*1000*x( t+h )
or
(1 + h*1000) * x( t+h ) ~ x( t )
or
x( t )
x( t+h ) ~ ----------
1 + h*1000
```
yielding the formula
```                  x( i )          x( 1 )
x( i+1 ) = ---------- = ----------------
1 + h*1000   ( 1 + h*1000 )^i
```
For the computed solution x(i) to approach 0 monotonically, we need to choose h so that 1+h*1000 > 1; this is true for all positive values of h, so we can take large step sizes, and find the solution x( t ) for large t in many fewer steps than Euler.

The accuracy with which the computed solution x(i) approximates the true solution x( t(i) still depends on h -- the smaller h is the more accurate the approximation -- but this is a topic for a class in numerical analysis of ordinary differential equations, like Math 228a.