centered_2nd_uniform

Family
finite_difference
Grid family
cartesian
Kind
scheme
Accuracy
O(dx²)
Applies to
grad(u), dim=x
Rule file
discretizations/finite_difference/centered_2nd_uniform.json
Tags
#finite-difference #centered #uniform #P0

Stencil

centered_2nd_uniform stencil — −1/(2dx) at i−1, +1/(2dx) at i+1
Two-point centered stencil — neighbors at offset ±1 with symmetric coefficients.

Coefficients

selector kindaxisoffsetcoeff
cartesian$x−1−1 / (2 dx)
cartesian$x+1+1 / (2 dx)

Combined as +. The result is the cell-centered approximation of the first spatial derivative with a leading error term (dx² / 6) · u′′′(x).

Discrete operator

Applied to a cell-centered field \(u_i = u(x_i)\) on a uniform axis with spacing \(\Delta x\), the rule produces the discrete first-derivative operator

$$\left(\frac{\partial u}{\partial x}\right)_i \;\approx\; \frac{u_{i+1} - u_{i-1}}{2\,\Delta x}.$$

Symmetric Taylor expansion of the two neighbors about \(x_i\),

$$u_{i\pm 1} \;=\; u_i \;\pm\; \Delta x\,u'_i \;+\; \tfrac{\Delta x^{2}}{2}\,u''_i \;\pm\; \tfrac{\Delta x^{3}}{6}\,u'''_i \;+\; \tfrac{\Delta x^{4}}{24}\,u^{(4)}_i \;\pm\; \cdots,$$

cancels the even-order terms when subtracted, giving

$$\frac{u_{i+1} - u_{i-1}}{2\,\Delta x} \;=\; u'_i \;+\; \tfrac{\Delta x^{2}}{6}\,u'''_i \;+\; O(\Delta x^{4}).$$

The scheme is therefore second-order accurate, with a purely dispersive leading error \(\tfrac{\Delta x^{2}}{6}\,u'''(x)\) and no numerical diffusion — contrast with upwind_1st, whose one-sided stencil introduces an explicit diffusive \((\Delta x / 2)\,u''(x)\) term.

Convergence

Empirical convergence — slope ≈ −2 on log-log
L∞ error of the centered stencil applied to u(x) = sin(2πx) on a periodic [0, 1] domain, sampled at cell centers. Empirical slope matches the expected −2 reference line.

The fixture under discretizations/finite_difference/centered_2nd_uniform/fixtures/convergence/ sets expected_min_order = 1.9 to tolerate minor pre-asymptotic drift on the 16 → 32 → 64 → 128 sequence.