# Second-order Neumann boundary condition discretization

Let the following problem $$\text{div}\left(\frac{\nabla u}{v}\right)=f\quad\text{on }]0,1[\times]0,1[,$$ where the given functions $v(x,y)$ and $f(x,y)$ are defined on $[0,1]$ and they are sufficiently smooth.

How can I discretize, by a second-order finite difference method, the boundary condition $\frac{\partial u}{\partial x}=0$ on the left boundary ?

Add ghost points at $(-h_x,y)$, then take $\frac{u(h_x,y)-u(-h_x,y)}{2h_x}=0$ so that $u(-h_x,y)=u(h_x,y)$. Then use the actual PDE at $(0,y)$ (which is where this value $u(-h_x,y)$ enters into the solution).
• You want to say $\frac{u(h_x,y)-u(-h_x,y)}{2h_x}$ – Houssam Jul 24 '17 at 16:39
• But $u(0,y)$ is not given also – Houssam Jul 24 '17 at 16:42
• @Houssam It doesn't have to be; ultimately you're trying to set up a system of linear equations for the values of $u$ at the grid points. The only a priori problem with defining the discretization of the PDE at $(0,y)$ is that $(-h_x,y)$ doesn't exist (for $y \neq 0,y \neq 1$, at least). Introducing the ghost point and then giving it an equation to relate it to the other $u$ values fixes that problem. – Ian Jul 24 '17 at 16:59
• Thanks Ian. But I think that the problem is more complicated: for example, if we consider the 1D problem $$\begin{cases}u''(x)=f(x)&\text{on }]0,1[\\u'(0)=0\text{ and }u(1)=0\end{cases}$$ then by discretizing $u'(0)=0$ by $u_{-1}=u_1$ and the equation on the interior points by $\dfrac{u_{i+1}-2u_i+u_{i-1}}{h^2}$, for $i=1,\ldots,n-1$, we obtain $n$ equations with $n+1$ unknowns $u_{-1},u_0,\ldots,u_{n-1}$. Moreover, the first equation $\dfrac{u_{2}-2u_1+u_0}{h^2}$ does not contain $u_{-1}$ – Houssam Jul 25 '17 at 13:03