Section 9.7 Implicit Euler method
The problematic behavior of the explicit Euler method disappears if, at the step \(n\text{,}\) we evaluate the right hand side at \(x_{n+1}\) rather than \(x_n\text{:}\)
\begin{equation*}
x_{n+1} = x_n + h f(t_{n+1},x_{n+1}).
\end{equation*}
This time, though, we do not evaluate \(x_{n+1}\) with Euler's method, as we did in case of Heun method, but rather we consider the relation above as an equation in \(x_{n+1}\) and look for its solution closest to \(x_{n}\text{.}\) This method is called Implicit Euler method and it is of global order 1. The word implicit referes to the fact that the relation above defines \(x_{n+1}\) only implicitly: an equation must be solved, usually numerically, to get its value. Although clearly much less trivial than its explicit counterpart, the implicit version has a great advantage: it behaves well with stiff problems! This can be seen explicitly in the example case:
\begin{equation*}
x_{n+1} = x_n - hkx_{n+1},\;\;x_1=1,
\end{equation*}
so that
\begin{equation*}
x_{n} = \frac{1}{(1+hk)^{n-1}}.
\end{equation*}
This sequence, for every value of \(h>0\text{,}\) does converge monotonically to 0, just like the exact solution! In the code below, we solve again the ODE \(\dot x = -15x\) but now with the Implicit Euler method. Notice that, in this case, there is no need to solve the equation numerically: \(x_{n+1} = \frac{x_n}{1+hk}.\) Below we solve with the implicit method the same ODE we have been solving so far with the explicit methods we covered, namely
\begin{equation*}
x' = \frac{\pi}{2x}\cos(\pi t),\;x(0)=\sqrt{5}/2.
\end{equation*}
This time we do need to solve numerically the equation
\begin{equation*}
x_{n+1} = x_n + h\frac{\pi}{2x_{n+1}}\cos(\pi t_{n+1}).
\end{equation*}
We do that using the secant method (see Section 3.5).