# Math Insight

### Applet: Forward Euler algorithm

This illustration of the forward Euler algorithm demonstrates the steps of its approximation to the solution of an ordinary differential equation (ODE). The exact solution $x(t)$ to the ODE \begin{align*}\diff{x}{t} &= F(x,t)\\x(t_0)&=x_0\end{align*} is shown by the green curve, for the case where $F(x,t)=\frac{1}{5} (-x + 4e^{-t/5})$ and initial conditions at $t_0=0$ are $x_0=1$. The forward Euler algorithm approximates the solution based on a discretization of time $t$ into steps of size $h$ (adjustable by the green slider), which we denote by $t_i= t_0+ih$ for $i=0,1,2, \ldots.$ The solution $x_{i+1}$ at time step $t_{i+1}$ is computed from the solution $x_{i}$ at the previous time step $t_{i}$ by approximating the right hand side $F(x,t)$ of the ODE as though it were the constant $F(x_{i},t_{i})$, giving $x_{i+1}= x_{i} + h F(x_i,t_i)$. The first 5 steps are

Applet file: forward_euler_algorithm.ggb