Suppose \(u = u(x,y)\) is a function of two variables that we only know at grid points \((x_{i},y_{j})\text{.}\) We will use the notation
\begin{equation*}
u_{i,j}= u(x_{i},y_{j})
\end{equation*}
frequently throughout the rest of the sections. We can suppose that the grid points are evenly spaced, with an increment of \(h\) in the \(x\) direction and \(k\) in the \(y\) direction. The central difference formulas for the partial derivatives would be
\begin{align*}
u_{x}(x_{i},y_{j}) \amp \approx \frac{1}{2h}\left( u_{i+1,j}- u_{i-1,j}\right) \quad\text{and}\\
u_{y}(x_{i},y_{j}) \amp \approx \frac{1}{2k}\left( u_{i,j+1}- u_{i,j-1}\right)\text{.}
\end{align*}
The second partial derivatives are
\begin{align*}
u_{xx}(x_{i},y_{j}) \amp \approx \frac{1}{h^{2}}\left( u_{i+1,j}-2u_{i,j}+ u_{i-1,j}\right) \quad\text{and}\\
u_{yy}(x_{i},y_{j}) \amp \approx \frac{1}{k^{2}}\left( u_{i,j+1}-2u_{i,j}+ u_{i,j-1}\right)\text{,}
\end{align*}
and the mixed partial derivative is
\begin{equation*}
u_{xy}(x_{i},y_{j}) \approx \frac{1}{4hk}\left( u_{i+1,j+1}- u_{i+1,j-1}- u_{i-1,j+1}+ u_{i-1,j-1}\right)\text{.}
\end{equation*}
Caution: Notice that we have indexed
\(u_{ij}\) so that as a matrix each row represents the values of
\(u\) at a certain
\(x_{i}\) and each column contains values at
\(y_{j}\text{.}\) The arrangement in the matrix does not coincide with the usual orientation of the
\(xy\)-plane.
Let’s consider an example. Let the values of \(u\) at \((x_{i},y_{j})\) be recorded in the matrix
\begin{equation}
(u_{ij}) = \left( \begin{array}{ccccc}5.1 & 6.5 & 7.5 & 8.1 & 8.4 \\ 5.5 & 6.8 & 7.8 & 8.3 & 8.9 \\ 5.5 & 6.9 & 9.0 & 8.4 & 9.1 \\ 5.4 & 9.6 & 9.1 & 8.6 & 9.4\end{array} \right)\tag{3.9.1}
\end{equation}
Assume the indices begin at 1, \(i\) is the index for rows and \(j\) the index for columns. Suppose that \(h = .5\) and \(k = .2\text{.}\) Then \(u_{y}(x_{2},y_{4})\) would be approximated by the central difference
\begin{equation*}
u_{y}(x_{2},y_{4}) \approx \frac{u_{2,5}- u_{2,3}}{2k}\approx \frac{8.9 - 7.8}{2 \cdot 0.2}= 2.75\text{.}
\end{equation*}
The partial derivative \(u_{xy}(x_{2},y_{4})\) is approximated by
\begin{equation*}
u_{xy}(x_{2},y_{4}) \approx \frac{u_{3,5}- u_{3,3}- u_{1,5}+ u_{1,3}}{4hk}\approx \frac{9.1 - 9.0 - 8.4 + 7.5}{4\cdot .5 \cdot .2}= -2\text{.}
\end{equation*}