Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I understand how to implement a discrete 2D poisson solution with Dirchlet boundary conditions. Using , you just replace any of the u_i,j that are on the source side of the boundary with the boundary values that you have. However, I don't understand how to implement the Neumann boundary condition. If you want to "match" the external derivative, wouldn't you have to just set the nodes that are on the target side of the boundary to a value that makes the derivative between the source boundary pixel and the target boundary pixel equal the derivative outside the boundary? If you do this, haven't you just simply "filled in" one node around the boundary and provided a slightly smaller version of the Dirchlet problem?

Can anyone explain this?

share|cite|improve this question
up vote 2 down vote accepted

Well, not exactly.

For Neumann BCs, you don't fill in any values, you just supply a relation between the values of the points on the boundary and the points right next to them. Think of this as having 2 different governing equations, one of them which is valid inside the boundary, and the other is valid only on the boundary.

When you discretize your system, you get a relation between the values $u_{ij}, u_{i+1j}, u_{i-1j}, u_{ij+1},u_{ij-1}$, etc..., that depends on your governing equation, now, this relation is valid INSIDE the domain only.

If for instance, you want to enforce the first derivative with respect to x to be equal to q, you write .

$u_{0j} - u_{1j} = q\delta_x$, this is itself a governing equation but is only valid between the values $i = 0$ and $1$.

So in your system, you have to alter the equations you are solving so that you have two equations instead of one, this is very simple to implement because the BC equation is always simpler than the governing equation.

In fact, the same thing holds for Dirichlet BCs, but in that case, your boundary equation is even simpler, it does not involve u at $i = 1$ at all, it is simply

$u_{0j} = p$

where $p$ is the prescribed Dirichlet condition, you can choose that your implementation solves this "second kind of equation" along with the governing equation as well, but this is trivial because it will try to solve $u_{0j} = p$ just to give you $u_{0j} = p$.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.