5
$\begingroup$

I am interested in the $n^{\mathrm{th}}$-order central difference of an expression $f$. The general form of the $n^{\mathrm{th}}$-order central difference is given by

$$\delta_h^n[f](x)=\sum_{i=0}^n(-1)^i {n \choose i}f(x+(\frac{n}{2}-i)h).$$

For odd $n$, the central difference will have $h$ multiplied by non-integers, which can often be problematic. According to this Wiki article, the problem can be circumvented by taking the average of $\delta^n[f](x-\frac{h}{2})$ and $\delta^n[f](x+\frac{h}{2})$.

What does that actually mean? Does this mean that I adjust the generalized formula from $f(x+(\frac{n}{2}-i)h)$ (only this part?) to e.g., $\delta^n[f](x-\frac{h}{2})$? And if so, $i$ is just a bookkeeping device. For example, for the third order difference, does it mean that I use the generalized formula for $i = \{0,2\}$ and the adjusted formula for $i = \{1,3\}$?

I know, of course, that it is also possible to use the explicit formula for, e.g., the third derivative. However, I am interested in the application of the generalized expression.

$\endgroup$
4
  • $\begingroup$ You get, for instance, $$3!f[x-2h, x-h, x+h, x+2h]=\frac{f(x+2h)-2f(x+h)+2f(x-h)-f(x-2h)}{2h^3}$$ as central approximation of the third derivative. $\endgroup$ Commented Jun 9, 2021 at 17:09
  • $\begingroup$ @LutzLehmann thanks for your commment. I know that this is the explicit formula for the third derivative. However, I need higher order derivatives and am therefore particularly interested in understanding the general form of the $nth$-order central difference. Maybe you have some tips for this as well? $\endgroup$
    – carl
    Commented Jun 9, 2021 at 20:11
  • $\begingroup$ The coefficient sequence is the one of $\sum c_iz^i=z^{-k}(z-1)^{2k-1}(z+1)/2$ for $n=2k-1$ and $f^{(n)}(x)\approx \sum c_if(x+ih)/h^n$. So use the binomial theorem and Pascal-triangle identities. $\endgroup$ Commented Jun 9, 2021 at 20:16
  • $\begingroup$ Thanks, maybe I just do not understand it because I am not a mathematician, but I do not see how that helps in answering my question. I know how to apply the generalized formula. I just noticed that for odd $n$, I have differences when I use the generalized formula compared to the explicit formula. This "error" does not occur for even $n$. So I am actually interested in understanding how to adjust the generalized formula for odd $n$ to get correct results. This problem is also mentioned in the linked article. However, I cannot figure out what steps to take to address this issue. $\endgroup$
    – carl
    Commented Jun 10, 2021 at 7:17

1 Answer 1

2
+50
$\begingroup$

The usual $3$-rd order central difference in accordance to the provided formula turns out to be:

$$f^{(3)}(x)\approx\frac{f(x+\frac32h)-3f(x+\frac12h)+3f(x-\frac12h)-f(x-\frac32h)}{h^3}\tag1$$

Yet in a discrete context, this is not desirable because we cannot evaluate $f$ at half integers. One option is to double $h$,

$$f^{(3)}(x)\approx\frac{f(x+3h)-3f(x+h)+3f(x-h)-f(x-3h)}{8h^3}\tag2$$

but this then skips over $f(x+2h)$ and $f(x-2h)$, and for higher order derivatives this becomes even worse.

Wikipedia as you linked suggests a different but still fairly simple alternative. It more or less boils down to estimating half integers by their neighboring integer values:

$$f\left(x+\frac h2\right)\approx\frac{f(x)+f(x+h)}2\tag3$$

Subsituting this into $(1)$ gives:

$$f^{(3)}(x)\approx\frac{f(x+2h)-2f(x+h)+2f(x-h)-f(x-2h)}{2h^3}\tag4$$

More generally, we may write this as:

$$f^{(2n+1)}(x)\approx\sum_{i=0}^n\binom{2n}i(-1)^i\frac{f(x+(n+1-i)h)-f(x-(n+1-i)h)}{2h^3}\tag5$$

For even derivatives, you may simply use the original formula since it doesn't involve any half-integer calculations.

$(5):$ Note that for $i=n$, the term is zero.

$\endgroup$
2
  • $\begingroup$ Thank you for your detailed reply. I now understand the issue. I also see why the substitution of (3) in (1) leads to (4). However, I don't really understand the more general term. First, considering $f^{(2n+1)}$. If I am interested in the 3rd derivative, $n$ must be 1 here ($2 \cdot 1 +1$). So with $n=1$ this gives the sum from $i=0$ to $0$. Second, having $n-1$ as the upper bound in the summation is because of the note to (5), is that correct? Third, is this the general expression for the 3rd derivative only? And if so, how can this be extended to any higher order odd $n$ derivative? $\endgroup$
    – carl
    Commented Jun 26, 2021 at 11:30
  • $\begingroup$ @carl That was my bad for the general term, the $h$'s should've gone out one further and the summation one more term. The general term is not just for the third derivative, that's what $(4)$ is. $\endgroup$ Commented Jun 26, 2021 at 13:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .