Wish to evaluate a generic function f((t)). Suppose we know a starting value, for example, f(0) = (c). We also know that we can express f((cdot)) through the ordinary differential equation
begin{eqnarray*}
frac{partial}{partial t} textrm{f}(t) = textrm{g}(textrm{f}(t)),
end{eqnarray*}
where (textrm{g}(cdot)) is a known function. Occasionally, we can solve the ordinary differential equation analytically. More often, a numerical solution is available. The easiest to explain and to implement is Euler’s method. To see this, consider a small (h) and use a straight line approximation for the derivative
begin{eqnarray*}
frac{partial}{partial t} textrm{f}(t) approx frac{textrm{f}(t+h)-textrm{f}(t)}{h}.
end{eqnarray*}
With this, we have an approximation to the ordinary differential equation
begin{eqnarray*}
textrm{f}(t+h) approx textrm{f}(t) + h textrm{g}(textrm{f}(t))
end{eqnarray*}
that we can evaluate recursively.
Example – Interest Theory
Suppose that (textrm{g}(t) = 0.05 t), a line, and f(0) = 1. Then, if (h=0.001), we have
begin{eqnarray*}
textrm{f}(t+h) approx textrm{f}(t) + (0.001) (0.05) textrm{f}(t) .
end{eqnarray*}
t | Approximate f(t) | Exact f(t) | Error |
0 | 1.0000000000 | 1.0000000000 | 0.0000000000 |
0.001 | 1.0000500000 | 1.0000500013 | 0.0000000013 |
0.002 | 1.0001000025 | 1.0001000050 | 0.0000000025 |
0.998 | 1.0511646632 | 1.0511659745 | 0.0000013113 |
0.999 | 1.0512172215 | 1.0512185341 | 0.0000013127 |
1 | 1.0512697823 | 1.0512710964 | 0.0000013140 |
For this example, we can evaluate f((cdot)) analytically, in that
begin{eqnarray*}
frac{partial}{partial t} textrm{f}(t) = 0.05 textrm{f}(t) Rightarrow frac{partial}{partial t} ln textrm{f}(t) = 0.05 ,
end{eqnarray*}
and so that, with f(0) = 1, we have ( textrm{f}(t) = e^{0.05 t}).