Asymmetric second difference quotient?

1.1k Views Asked by At

I need to find (approximate) the second derivative of a discrete function. Usually I would approximate the second derivative with

$$f''(x)\approx\frac{f(x+h)-2f(x)+f(x-h)}{h^2}\tag{1}$$

In my case, however, the $x$ values at which $f$ is known are distributed non-uniformly. So the "forward" $h$ and "backward" $h$ can be different $h_1\neq h_2$.

Intuitively I would go with something like

$$f''(x)\approx\frac{f(x+h_1)-2f(x)+f(x-h_2)}{h_1h_2}\tag{2}$$

but when I start from the forward and backward difference I end up with

$$f''(x)\approx\frac{\frac{f(x+h_1)-f(x)}{h_1}-\frac{f(x)-f(x-h_2)}{h_2}}{?}$$

and I don't know what to put in the quotient. I guess the arithmetic mean $\frac{h_1+h_2}{2}$ would be a good choice but that leads to

$$f''(x)\approx\frac{\frac{2h_2}{h_1+h_2}f(x+h_1)-2f(x)+\frac{2h_1}{h_1+h_2}f(x-h_2)}{h_1h_2}\tag{3}$$

which for $h_1=h_2$ simplifies to $(1)$ but is not the same as $(2)$.

Is $(2)$ or $(3)$ the right way to do this or is there another way?

2

There are 2 best solutions below

0
On BEST ANSWER

I agree that (3) is correct. The reason is that it is easy to check that (3) gives the correct result if $f(x) = 1$, if $f(x) = x$, and with a bit more work if $f(x) = x^2$. Hence this also shows that (3) is indeed a solution of the linear equation system of the previous answer.

0
On

The way I think about it would be to have a polynomial of degree 2 describe the three points and the second derivative would be 2 times the coefficient of $x^2$ : $$ f(x+h_1)=a\,(x+h_1)^2+b\,(x+h_1)+c\\ f(x) = a\,x^2+b\,x+c\\ f(x+h_2)=a\,(x+h_2)^2+b\,(x+h_2)+c\\ $$ this can be interpreted as a linear equation system: $$ \begin{matrix} a\\ b\\ c\\ \end{matrix} \times \begin{matrix} (x+h_1)^2&x+h_1&1\\x^2&x&1\\(x+h_2)^2&x+h_2&1\\\end{matrix}=\begin{matrix}f(x+h_1)\\x\\f(x+h_2)\end{matrix} $$ Which can be solved by cramers rule, but the general solution for $a$ will fill two lines, if you want I will give it a go.