(Sorry for my bad english)
I want to approximate a solution $u$ (with sufficient regularity) of the problem : $$\partial_x\left(v\partial_xu\right)=f,\qquad\textrm{ on }[0,1],$$ with $f,v$ function ($\mathcal{C}^2$ if we need), and with the condition $u(0)=u(1)=0$.
I decompose $[0,1]$ in $\{x_0=0, \ldots , x_i = ih, \ldots , x_{N+1}=1\}$. Next I defined $u_i\simeq u(x_i)$ and $v_{i+\frac{1}{2}}\simeq v(x_i + \frac{1}{2}h)$. I have a "sequence" (maybe a bad traduction) that I don't understand how to find it : $$\begin{cases} u_0=u_{N+1}=0 \\ \frac{1}{h^2}\left( v_{i+\frac{1}{2}}(u_{i+1}-u_i) - v_{i-\frac{1}{2}}(u_i-u_{i-1}) \right)=f(x_i) \end{cases}\\$$
The most closest I find is : $$ \frac{1}{h^2}\left( v_{i+\frac{1}{2}}(u_{i+1}-u_i) - v_{i-\frac{1}{2}}(u_{i+1}-u_i) \right)=f(x_i) $$ that I find with writing $\partial_x\left(v\partial_xu\right) = \partial_xv\partial_xu-v\partial_x^2u$, next with approximate $v\partial_x^2u$ by 0, next by approximate $$\begin{cases} \partial_xv_i \simeq \dfrac{v_{i+\frac{1}{2}}-v_{i-\frac{1}{2}}}{h} \\ \partial_xu_i \simeq \dfrac{u_{i+1}-u_i}{h} \end{cases}$$ But can I suppose $v\partial_x^2u$ approximate by 0 ? Maybe, what I don't understand is the approximation of $v$ with a décomposition of switch by $\frac{1}{2}$.
Thanks.
Just decompose your equation as $∂_xg=f$, $g=v∂_xu$. Then the approximation with the central difference quotient to step size $h/2$ for the first equation gives $$ f(x_i)=\frac{g(x_i+h/2)-g(x_i-h/2)}{h} $$ Now insert the same central difference quotients with step size $h/2$ for $u$ into the evaluation of $g$, $$ g(x_i+h/2)=v(x_i+h/2)\frac{u(x_i+h)-u(x_i)}{h} $$ This gives the difference equation as was claimed, $$ f(x_i)=\frac1{h^2}(v_{i+1/2}(u_{i+1}-u_i)-v_{i-1/2}(u_i-u_{i-1})) $$