I'm trying to express the following in finite differences:
$\frac{d}{dx}\left[ A(x)\frac{d\, u(x)}{dx} \right].$
Let $h$ be the step size and $x_{i-1} = x_i - h$ and $x_{i+ 1} = x_i + h$
If I take centered differences evaluated in $x_i$, I get:
$\begin{align*}\left\{\frac{d}{dx}\left[ A(x)\frac{d\, u(x)}{dx}\right]\right\}_i &= \frac{\left[A(x)\frac{d\, u(x)}{dx}\right]_{i+1/2} - \left[A(x)\frac{d\, u(x)}{dx}\right]_{i-1/2}}{h} \\ &= \frac{A_{i+1/2}\left[\frac{u_{i+1}-u_{i}}{h}\right] - A_{i-1/2}\left[\frac{u_{i}-u_{i-1}}{h}\right]}{h} \end{align*}$
So, if I use centered differences I would have to have values for $A$ at $i + \frac 12$ and $A$ at $i - \frac 12$; however those nodes don't exist (in my stencil I only have $i \pm$ integer nodes); is that correct? If I use forward or backward differences I need A values at $i$, $i + 1$, $i + 2$ and at $i$, $i -1$, $i -2$ respectively.
Am I on the correct path?
I would really appreciate any hint.
Thanks in advance,
Federico