I have to calculate the normal derivative of a function $f(i,j)$ on a domain with an irregular boundary. Let's say something like this:

x x x x
0 x 0 0
0 0 0 0

where x indicates a solid boundary.

Which is the correct way to calculate the normal derivative of $f$ at the grid point (1,2) and (3,2)?

Should I simply sum the two partial derivatives?

For example, for the grid point (1,2), would this work?

$$\frac{\partial f}{\partial \hat{n}}\bigg\rvert_{(i=1,~j=2)} = \frac{\partial f}{\partial x}\bigg\rvert_{(i=1,~j=2)} + \frac{\partial f}{\partial y}\bigg\rvert_{(i=1,~j=2)} $$

  • $\begingroup$ To clarify, i is the column, j is the row, and they are both starting from zero? $\endgroup$
    – Tyberius
    Apr 23, 2018 at 14:30
  • $\begingroup$ @Tyberius i is the column, j is the row, they start from 1 and from the lower left corner. The problematic points are the ones where the boundary forms corners. $\endgroup$
    – shamalaia
    Apr 23, 2018 at 15:14
  • $\begingroup$ I'm just used to the opposite ordering and one of your expressions has f(1,0) $\endgroup$
    – Tyberius
    Apr 23, 2018 at 16:19
  • $\begingroup$ @Tyberius I edited the question in a way to not get confused by indeces $\endgroup$
    – shamalaia
    Apr 26, 2018 at 0:55

1 Answer 1


First of all, there is a distinction between a continuous boundary having regions with ill-defined normal derivative - and its discretization having regions will ill-defined derivatives. The question describes a bit confusing discretized boundary with one point sticking out. I have a hard time imagining a boundary that could be discretized this way to solve some problem with just one point sticking out.

A classic example of a continuous boundary in 2D with such problems would be a corner, where at a corner point the direction of the normal will be undefined; thus, resulting in an ill-defined normal derivative.

So, if the normal is ill-defined -> the normal derivative is ill-defined as well.

Now, a lot depends on what you actually intend to do with your normal derivatives. For example, you might want to enforce some boundary conditions on them or use their values in some other method that requires them.

I don't think that taking the definition of a normal derivative at such bad point as a sum of two partial derivatives has any physical meaning. For a crude approximation, you might consider your corner normal to be defined either as $\hat{n}=\hat{x}$ or $\hat{n}=\hat{y}$, effectively assigning a corner to a certain part of the boundary having a well-defined normal. I have also seen averaging out the values of those derivatives (which will be 0.5 times your proposed result) being done. However, that's a decision not to handle the issue.

Some approaches would avoid having the corner point at all (having only points very close to the point with the undefined normal) or instead of a normal derivative, a reformulation with adding additional equations might be required.

The paper

features a nice overview (or references) of different techniques to handle those situations for corners, which might be useful for your needs.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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