< >
 Ch. 1 Sec. 3

## 1.3b Differencing in 2 dimensions

Let $f(x,y)$ be given for equidistant values of $x$ and $y$, respectively:

$\begin{eqnarray} f_{i,j} &\equiv& f(x_{0}+i \Delta x, y_{0}+j \Delta y) \end{eqnarray}$

First and second derivatives on a grid will be needed.

### 1.3.3 First Derivatives (2D)

We will use the short notation
$f_{x} \equiv \frac{\textstyle \partial f(x,y)}{\textstyle \partial x}$

etc. for the partial derivatives of the function $f$ with respect to its arguments.
Note: One of the arguments may be the time $t$: $f = f(x,t)$ etc.

For the numerical treatment of partial differential equations (PDEs) we again have to construct discrete approximations to the partial derivatives at the base points $(x_{i},y_{j})$.

Using the DNGF, DNGB, or DST approximation of lowest order, we have

$\begin{eqnarray} {\left[ F_{x} \right]}_{i,j} & \approx & \frac{\textstyle 1}{\textstyle \Delta x} \left[ f_{i+1,j} - f_{i,j} \right] + O[\Delta x] \equiv \frac{\textstyle \Delta_{i} f_{i,j}}{\textstyle \Delta x} + O[\Delta x] \end{eqnarray}$

or
$\begin{eqnarray} {\left[ F_{x} \right]}_{i,j} & \approx & \frac{\textstyle 1}{\textstyle \Delta x} \left[ f_{i,j} - f_{i-1,j} \right] + O[\Delta x] \equiv \frac{\textstyle \nabla_{i} f_{i,j}}{\textstyle \Delta x} + O[\Delta x] \end{eqnarray}$

or
$\begin{eqnarray} {\left[ F_{x} \right]}_{i,j} & \approx & \frac{\textstyle 1}{\textstyle 2 \Delta x} \left[ f_{i+1,j} - f_{i-1,j} \right] + O[(\Delta x)^{2}] \\ && \\ & \equiv & \frac{\textstyle \mu \delta_{i} f_{i,j}}{\textstyle \Delta x} + O[(\Delta x)^{2}] \end{eqnarray}$

Again, the central difference scheme is superior.

### 1.3.4 Second derivatives (2D)

By again fixing one of the independent variables - $y$, say - and considering only $f_{xx}$, we obtain, in terms of the Stirling (centered) approximation,

$\begin{eqnarray} [F_{xx}]_{i,j} & \approx & \frac{\textstyle 1}{\textstyle (\Delta x)^{2}} [f_{i+1,j}-2f_{i,j}+f_{i-1,j}] + O[(\Delta x)^{2}] \\ && \\ & \equiv & \frac{\textstyle \delta_{i}^{2}f_{i,j}}{\textstyle (\Delta x)^{2}} + O[(\Delta x)^{2}] \end{eqnarray}$

Analogous (and less accurate) formulae are valid within the NGF- and NGB-approximations, respectively.

### Mixed derivatives

Approximating $f_{xy}$ use the same kind of approximation with respect to both the $x$- and the $y$-direction. (This may not hold if $x$ and $y$ have a different character, e.g. one space and one time variable.) Again applying Stirling's procedure we find

$\begin{eqnarray} [F_{xy}]_{i,j} & \approx & \frac{\textstyle 1}{\textstyle 4\Delta x \Delta y} \left[ f_{i+1,j+1}-f_{i+1,j-1} - f_{i-1,j+1}+f_{i-1,j-1} \right] +O[\Delta x \Delta y] \\ && \\ & \equiv & \frac{\textstyle \mu \delta_{i}}{\textstyle \Delta x} \left[\frac{\textstyle \mu \delta_{j} f_{i,j}} {\textstyle \Delta y} \right] + O[\Delta x \Delta y] \end{eqnarray}$

### Curvature of a function f(x,y)

To find the local curvature at the grid point $(i,j)$ we have to apply the nabla operator $\nabla$ twice.(*) There are two ways:
Either "difference" along the grid axes,

$\begin{eqnarray} \nabla^{2} f(x,y) &\approx& \frac{1}{(\Delta l)^{2}} \left[ f_{i+1,j}+f_{i,j+1}+f_{i-1,j}+f_{i,j-1}-4f_{i,j}\right] \end{eqnarray}$

or apply "diagonal differencing", writing

$\begin{eqnarray} && \nabla^{2} f(x,y) \approx \frac{\textstyle 1}{\textstyle 2(\Delta l)^{2}} \left[ f_{i+1,j+1}+f_{i-1,j+1} + f_{i-1,j-1}+f_{i+1,j-1}-4f_{i,j} \right] \end{eqnarray}$

 Axial vs. diagonal differencing
(*) Note that the nabla operator $\nabla$ mentioned here is not to be mixed up with the backward difference for which we use the same symbol.

vesely 2005-10-10

 < >