Numerical partial differentiation.
The following two-dimensional data for the x component of velocity u as a function of the two coordinates x and y is measured from an experiment:
(a) Using central difference approximations, calculate ∂u/∂x, ∂u/(∂y), ∂²u/∂y², and ∂²u/∂x∂y at the point (2,2)
(b) Using a three-point forward difference approximation, calculate ∂u/∂x at the point (2,2).
(c) Using a three-point forward difference approximation, calculate ∂u/∂y at the point (2,1).
(a) In this part x_{i}=2, y_{i}=2, x_{i-1}=1.5, x_{i+1}=2.5, y_{i-1}=1, y_{i+1}=3, h_{x}=0.5, h_{y}=1.
Using Eqs. (8.59) and (8.60),
\begin{aligned} & \left.\frac{\partial f}{\partial x}\right|_{\substack{x=x_i \\ y=y_i}}=\frac{f\left(x_{i+1}, y_i\right)-f\left(x_i, y_i\right)}{h_x} \qquad (8.59) \\ & \left.\frac{\partial f}{\partial y}\right|_{\substack{x=x_i \\ y=y_i}}=\frac{f\left(x_i, y_{i+1}\right)-f\left(x_i, y_i\right)}{h_y} \qquad (8.60) \end{aligned}
the partial derivatives ∂f/∂x and ∂u/∂y are:
\begin{gathered} \left.\frac{\partial u}{\partial x}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{u\left(x_{i+1}, y_{i}\right)-u\left(x_{i-1}, y_{i}\right)}{2 h_{x}}=\frac{u(2.5,2)-u(1.5,2)}{2 \cdot 0.5}=\frac{437-291}{1}=146 \\ \left.\frac{\partial u}{\partial y}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{u\left(x_{i}, y_{i+1}\right)-u\left(x_{i}, y_{i-1}\right)}{2 h_{y}}=\frac{u(2,3)-u(2,1)}{2 \cdot 1}=\frac{448-250}{2}=99 \end{gathered}
The second partial derivative ∂²u/∂y² is calculated with Eq. (8.64):
\left.\frac{\partial^{2} u}{\partial y^{2}}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{u\left(x_{i}, y_{i-1}\right)-2 u\left(x_{i}, y_{i}\right)+u\left(x_{i}, y_{i+1}\right)}{h_{y}{ }^{2}}=\frac{250-(2 \cdot 361)+448}{1^{2}}=-24
The second mixed derivative ∂²u/∂x∂y is given by Eq. (8.65):
\begin{aligned} & \left.\frac{\partial^{2} u}{\partial x \partial y}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{\left[u\left(x_{i+1}, y_{i+1}\right)-u\left(x_{i-1}, y_{i+1}\right)\right]-\left[u\left(x_{i+1}, y_{i-1}\right)-u\left(x_{i-1}, y_{i-1}\right)\right]}{2 h_{x} \cdot 2 h_{y}} \\ & =\frac{[u(2.5,3)-u(1.5,3)]-[u(2.5,1)-u(1.5,1)]}{2 \cdot 0.5 \cdot 2 \cdot 1}=\frac{[557-350]-[298-205]}{2 \cdot 0.5 \cdot 2 \cdot 1}=57 \end{aligned}
(b) In this part x_{i}=2, x_{i+1}=2.5, x_{i+2}=3.0, y_{i}=2, and h_{x}=0.5. The formula for the partial derivative ∂u/∂x with the three-points forward finite difference formula can be written from the formula for the first derivative in Section 8.4.
\begin{gathered} \left.\frac{\partial u}{\partial x}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{-3 u\left(x_{i}, y_{i}\right)+4 u\left(x_{i+1}, y_{i}\right)-u\left(x_{i+2}, y_{i}\right)}{2 h_{x}}= \\ =\frac{-3 u(2,2)+4 u(2.5,2)-u(3.0,2)}{2 \cdot 0.5}=\frac{-3 \cdot 361+4 \cdot 437-517}{2 \cdot 0.5}=148 \end{gathered}
(c) In this part y_{i}=1, y_{i+1}=2, y_{i+2}=3, x_{i}=2, and h_{y}=1.0. The formula for the partial derivative ∂u /∂y with the three-points forward difference formula can be written from the formula for the first derivative in Section 8.4.
\begin{aligned} & \left.\frac{\partial u}{\partial y}\right|_{\substack{x=x_{i} \\ y=y_{i}}}=\frac{-3 u\left(x_{i}, y_{i}\right)+4 u\left(x_{i}, y_{i+1}\right)-u\left(x_{i}, y_{i+2}\right)}{2 h_{y}}= \\ & =\frac{-3 u(2,1)+4 u(2,2)-u(2,3)}{2 \cdot 1}=\frac{-3 \cdot 250+4 \cdot 361-448}{2 \cdot 1}=123 \end{aligned}