# Forward Euler PDE (grid method) misunderstanding - Is the question missing a detail

We are interested in solving the advection equation $$u_t = u_x$$ where $$0\leq x < 1$$, $$t \geq 0$$

with periodic boundary conditions and $$u(x,0) = f(x),f(x) = f(x+1)$$ In the grid $$x_0,x_1,\dots x_N$$, $$t_0,t_1,\dots t_N$$.

using the forward euler method, or $$\frac{v(x_j,t_{n+1}) - v(x_j,t_n)}{\Delta t}= \frac{v(x_{j+1},t_n)-v(x_{j-1},t_n)}{2\Delta x}$$ where $$v$$ is the approximation of $$u$$ at the grid points.

What I don't understand:

We are essentially using $$v(x_{j-1},t_n), v(x_j,t_n),v(x_{j+1},t_n)$$ to calculate $$v(x_j,t_{n+1})$$. Initially this is fine because $$v(x_j,0)$$ is known for all $$j$$, but how would we calculate $$v(x_0,t_1)$$? we can't, since that would require us to know $$v(x_{-1}, t_0)$$ which doesn't exist. And this issue propagates, each new $$t_n$$ we can calculate one less point than $$t_{n-1}$$.

What am I missing?

Your recurrence relation for the forward time, central space scheme is $$u_{j}^{n+1} = -\gamma u_{j-1}^{n} + u_{j}^{n} + \gamma u_{j+1}^{n}$$ where $$\gamma = \Delta t/(2\Delta x)$$. Writing the first few terms out (for $$j=1,..,M-1$$) yields

\begin{align} u_{1}^{n+1} &= -\gamma u_{0}^{n} + u_{1}^{n} + \gamma u_{2}^{n} \\ u_{2}^{n+1} &= -\gamma u_{1}^{n} + u_{2}^{n} + \gamma u_{3}^{n} \\ \vdots \\ u_{M-1}^{n+1} &= -\gamma u_{M-2}^{n} + u_{M-1}^{n} + \gamma u_{M}^{n} \end{align}

which we can write as a matrix

$$\begin{pmatrix} u_{1}^{n+1} \\ u_{2}^{n+1} \\ u_{3}^{n+1} \\ \vdots \\ u_{M-1}^{n+1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} u_{1}^{n} \\ u_{2}^{n} \\ u_{3}^{n} \\ \vdots \\ u_{M-1}^{n} \end{pmatrix} + \begin{pmatrix} -\gamma u_{0}^{n} \\ 0 \\ 0 \\ \vdots \\ \gamma u_{M}^{n} \end{pmatrix} \tag 1$$

To answer your question 'how would we calculate $$v(x_{0},t_{1})$$?', periodic boundary conditions imply $$u_{0}^{n} = u_{M-1}^{n}$$ and $$u_{1}^{n} = u_{M}^{n}$$ for all $$n$$ (time). Therefore, we can rewrite the matrix equation $$(1)$$ as

$$\begin{pmatrix} u_{1}^{n+1} \\ u_{2}^{n+1} \\ u_{3}^{n+1} \\ \vdots \\ u_{M-1}^{n+1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & -\gamma \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ \gamma & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} u_{1}^{n} \\ u_{2}^{n} \\ u_{3}^{n} \\ \vdots \\ u_{M-1}^{n} \end{pmatrix} \tag 2$$

We also know that the initial condition $$u(x,0) = f(x) \implies u_{j}^{0} = f_{j}$$ where $$f_{j} = f(x_{j})$$ is $$f(x)$$ evaluated at the spatial grid points $$x_{j}$$. So for the first iteration we need to solve

$$\begin{pmatrix} u_{1}^{1} \\ u_{2}^{1} \\ u_{3}^{1} \\ \vdots \\ u_{M-1}^{1} \end{pmatrix} = \begin{pmatrix} 1 & \gamma & & & -\gamma \\ -\gamma & 1 & \gamma & \\ & -\gamma & 1 & \gamma & \\ \\ \gamma & & & -\gamma & 1 \end{pmatrix} \begin{pmatrix} f_{1} \\ f_{2} \\ f_{3} \\ \vdots \\ f_{M-1} \end{pmatrix}$$

and thereafter we solve $$(2)$$.

$$\frac{v(x_{j}, t_{n+1}) -v(x_{j},t_{n}) }{\Delta t} = \frac{v(x_{j+1},t_{n}) -v(x_{j-1},t_{n})}{2 \Delta x} \tag{1}$$

you get this

$$v(x_{j},t_{n+1})- v(x_{j},t_{n}) = \frac{\Delta t(v(x_{j+1},t_{n}) -v(x_{j-1},t_{n}))}{2 \Delta x} \tag{2}$$

$$v(x_{j},t_{n+1}) = v(x_{j},t_{n}) + \frac{\Delta t(v(x_{j+1},t_{n}) -v(x_{j-1},t_{n}))}{2 \Delta x} \tag{3}$$

you said we have the initial condition where $$t_{n} = 0$$ . The grid is only between $$0 \leq x \leq 1$$ then you discretize it so $$x_{j-1}$$ is the first point in the array. Forward euler is the most basic runge kutte method.

• Sorry, I don't follow. Why does it matter how I discretize the grid? at any rate I will have that $v(0, \Delta t) = v(0,0) + \frac{\Delta t (v(\Delta x, 0) - v(-\Delta x, 0)}{2\Delta x}$ Oct 18, 2018 at 6:00
• A similar thing happens at the other boundary, $v(1, t_N)$ will require us to know $v(1+\Delta x, T_{N-1})$. Oct 18, 2018 at 6:02
• you have to define the boundary conditions the first and last points in the array are the boundaries.
– user3417
Oct 18, 2018 at 6:04
• you have boundary conditions.
– user3417
Oct 18, 2018 at 6:05
• @OriaGruber: Your problem is periodic, periodic boundary conditions give the possibility for periodic continuation of the solution. So you not only have $f(x+1)=f(x)$ but also $u(x+1,t)=u(x,1)$. Thus $u(−Δx,t)=u(1−Δx,t)$, $u(1+Δx,t)=u(Δx,t)$. Oct 18, 2018 at 12:07