Implicit Scheme
We could also have used a midpoint approximation for the first derivative, resulting in
$$
\begin{equation*}
u_t\approx \frac{u(x_i,t_j+\Delta t)-u(x_i,t_j-\Delta t)}{2\Delta t},
\end{equation*}
$$
with a truncation error \( O(\Delta t^2) \).
Here we will stick to the backward formula and come back to the latter below.
For the second derivative we use however
$$
\begin{equation*}
u_{xx}\approx \frac{u(x_i+\Delta x,t_j)-2u(x_i,t_j)+u(x_i-\Delta x,t_j)}{\Delta x^2},
\end{equation*}
$$
and define again \( \alpha = \Delta t/\Delta x^2 \).