---
# System prepended metadata

title: Untitled

---

### Test
For the **forward difference in time and central difference in space [Implicit euler method]** we get the following difference scheme:

$$(\frac{U_{i, j+1} - U_{i, j}}{k}) - r i h (\frac{U_{i+1, j} - U_{i-1, j}}{2h}) - \frac{1}{2}\sigma^2 i^2 h^2 (\frac{U_{i+1, j} - 2U_{i, j} + U_{i-1, j}}{h^2}) + cU_{i,j} = 0$$

Which again can be formulated in simpler terms with:

$$\alpha_i = \frac{1}{2} i k (\sigma^2 i - r)$$
$$\beta_i = k(\sigma^2 i^2 + c)$$
$$\gamma_i = \frac{1}{2} i k(\sigma^2 i + r)$$

Resulting in the scheme:

$$U_{i, j+1} = \alpha_i U_{i-1, j} + (1 - \beta_i) U_{i, j} + \gamma_i U_{i+1, j}$$
matrix form:

$$
\begin{bmatrix}
2\alpha_1 + 1 + \beta_1 & \gamma_1 - \alpha_1 & 0 & 0 & \dots & 0 \\
\alpha_2 & 1 + \beta_2 & \gamma_2 & 0 & \dots & 0 \\
0 &\alpha_3 & 1 + \beta_3 & \gamma_3 & \dots & 0 \\
\vdots & \vdots & \ddots &  & \ddots & 0 \\
0 & 0 & \dots & & & \gamma_{M-2}\\
0 & 0 & \dots & &\alpha_{M-1} - \gamma_{M-1} & 2\gamma_{M-1} + 1 + \beta_{M-1}
\end{bmatrix}
\begin{bmatrix}
U_{1, j} \\
U_{2, j} \\
U_{3, j} \\
\vdots \\
U_{M-1, j}
\end{bmatrix}=
\begin{bmatrix}
U_{1, j+1} \\
U_{2, j+1} \\
U_{3, j+1} \\
\vdots \\
U_{M-1, j+1}
\end{bmatrix}
$$