Derivative of Lattice Laplacian The lattice Laplacian is defined as,
$$
\nabla_L^2x_j \equiv \frac{x_{j+1} - 2x_j + x_{j-1}}{a^2}
$$
where the lattice spacing, $a$, is a constant.
The derivative, with respect to $x_i$, then gives,
$$
\frac{\partial}{\partial x_i} \nabla_L^2x_j = \frac{\delta_{i(j+1)} - 2\delta_{ij} + \delta_{i(j-1)}}{a^2}
=
\begin{cases}
a^{-2}\ &\text{for}\ i=j+1\\
-2a^{-2}\ &\text{for}\ i=j\\
a^{-2}\ &\text{for}\ i=j-1
\end{cases}
$$
I am not sure intuitively why this is the case. I expected the derivative of the laplacian to be a function rather than a piecewise constant?

$\def\m#1{\left[\begin{array}{r}#1\end{array}\right]}\def\p#1#2{\frac{\partial #1}{\partial #2}}$You
can approach this problem in a purely matrix form using the Up Shift Matrix.
For example, for $\,n=3$
$$U = \m{0&1&0\\0&0&1\\0&0&0}$$
Then the lattice vector could be written as
$$\eqalign{
y &= \left(\frac{U-2I+U^T}{a^2}\right)x \;\doteq\; Lx \\
}$$
This is a linear equation and the gradient with respect to $x$ is simply
$$\eqalign{
\p{y}{x} &= L \\\\
}$$
NB: If your lattice is circulant, then you may want to use a cyclic permutation instead of a shift, i.e.
$$U = \m{0&1&0\\0&0&1\\1&0&0}$$
