discretize.utils.ddx

discretize.utils.ddx(n)[source]

Create 1D difference (derivative) operator from nodes to centers.

For n cells, the 1D difference (derivative) operator from nodes to centers is sparse, has shape (n, n+1) and takes the form:

\[ \begin{align}\begin{aligned}\begin{bmatrix} -1 & \; 1 & & & \\& -1 & \; 1 & & \\& & \ddots & \ddots & \\& & & -1 & \; 1 \; \end{bmatrix}\end{aligned}\end{align} \]
Parameters
nint

Number of cells

Returns
(n, n + 1) scipy.sparse.csr_matrix

The 1D difference operator from nodes to centers.