Discretization for $\partial_tu = \partial_x[g\times\partial_xu]$ In paper Efficient and Reliable Schemes for Nonlinear Diffusion Filtering i have difficulty to understand the following step.
We have equation and its discretization in 1D case:
$$\partial_tu = \partial_x[g\times\partial_xu]$$
$$\frac{u_i^{k+1}-u_i^k}{\tau} = \sum_{j\in \mathcal N(i)}\frac{g_j^k+g_i^k}{2h^2}(u_j^k-u_i^k), $$
where $\mathcal N(i)$ is the set of the two neighbors of pixel $i$.
I don't get how did the authors get this discretization.
 A: It looks like a second-order discretization using a centered finite difference approximation of $u_x$.
\begin{align}
\partial_x[g\times\partial_x u] &\approx \dfrac{g_{i+1/2} (u_x)_{i+1/2} - g_{i-1/2} (u_x)_{i-1/2}}{2(h/2)} \tag{1} \\
&\approx \dfrac{g_{i+1/2} \dfrac{u_{i+1}-u_i}{2(h/2)} - g_{i-1/2} \dfrac{u_i-u_{i-1}}{2(h/2)}}{2(h/2)} \tag{2} \\
&= \dfrac{g_{i+1/2} (u_{i+1}-u_i)}{h^2} + \dfrac{g_{i-1/2}(u_{i-1} - u_i)}{h^2} \tag{3} \\
&\approx \dfrac{\dfrac{g_{i+1}+g_i}{2} (u_{i+1}-u_i)}{h^2} + \dfrac{\dfrac{g_i+g_{i-1}}{2}(u_{i-1} - u_i)}{h^2} \tag{4} \\
&= \dfrac{g_{i+1}+g_i}{2h^2}(u_{i+1}-u_i) + \dfrac{g_{i-1}+g_i}{2h^2}(u_{i-1} - u_i) \tag{5} 
\end{align}


*

*Second-order accurate, central finite difference approximation of $\partial_x[F]$ at $x_i$, where $F:=g\times\partial_x u$.

*Second-order accurate, central finite difference approximation of $u_x$ at  $x_{i+1/2}:=\frac12 (x_i + x_{i+1})$ and $x_{i-1/2}:=\frac12 (x_i + x_{i-1})$.

*Rearranging / simplification.

*Second-order accurate approximation of $g_{i+1/2}$ and $g_{i-1/2}$ by $\frac12 (g_{i+1} + g_i)$ and $\frac12 (g_{i-1} + g_i)$, respectively.

*Rearranging / simplification.  Equation (5) is the same as the right-hand side of $$\frac{u_i^{k+1}-u_i^k}{\tau} = \sum_{j\in \mathcal N(i)}\frac{g_j^k+g_i^k}{2h^2}(u_j^k-u_i^k)$$ (after "expanding" the sum) so we are done.

