# How can we calculate mixed derivatives numerically using the Chebyshev derivative matrix?

Using the Chebyshev derivative matrix $$D$$, we can numerically approximate the first and second derivative of a function by doing matrix multiplication:

$${df(x) \over dx} = Df(x) \tag 1$$ $${d^2f(x) \over dx^2} = D^2f(x) \tag 2$$

where $$x \in \{x_0,x_1,...x_n\}$$, $$x_j=\cos(j \pi/n)$$, $$j \in \{0, 1,...n\}$$.

When we want to calculate the Laplacian of a function we can use the Kronecker product of matrices:

$$\nabla ^2f(x, y) = (I \otimes D^2 + D^2 \otimes I)\bar f \tag 3$$

where $$\bar f$$ is a vector obtained by stacking the columns of matrix $$f(x, y)$$. My question is, how can we find the mixed partial derivatives of a function using the Chebyshev derivative matrix? For instance, how would we calculate:

$${\partial^2 f(x,y) \over \partial x \partial y}=? \tag 4$$ and $${\partial^3 f(x,y) \over \partial x^2 \partial y}=? \tag 5$$

Note: Your nomenclature is only valid on Cartesian elements. If you want to calculate derivatives on arbitrary shapes you also have to consider spatial metric terms.

Answer: To keep it simple, we stick to the special case. We can define a 2D differential operator $$\mathbf{D}_2$$ on a tensor-product element with

$$\xi$$-direction (or $$x$$):

$$\mathbf{D}_2^{\xi} = \mathbf{D}_1 \otimes \mathbf{I}_1$$

$$\eta$$-direction (or $$y$$):

$$\mathbf{D}_2^{\eta} = \mathbf{I}_1 \otimes \mathbf{D}_1$$

The Laplacian is defined as

$$\mathbf{\mathcal{L}}_2 := \mathbf{D}_2^{\xi}\mathbf{D}_2^{\xi} +\mathbf{D}_2^{\eta} \mathbf{D}_2^{\eta} \\ \hspace{0.75cm} = (\mathbf{D}_1\otimes\mathbf{I}_1) (\mathbf{D_1}\otimes\mathbf{I_1}) + (\mathbf{I_1}\otimes\mathbf{D_1}) (\mathbf{I}_1 \otimes\mathbf{D}_1)\\ \hspace{0.75cm} = (\mathbf{D}_1\mathbf{D}_1)\otimes (\mathbf{I_1}\mathbf{I_1}) + (\mathbf{I_1}\mathbf{I_1}) \otimes (\mathbf{D}_1 \mathbf{D}_1)$$

For mixed derivatives you simply have to apply both operators one after the other

$$\partial_{\xi \eta}:= \mathbf{D}_2^{\xi}\mathbf{D}_2^{\eta} \\ \hspace{0.8cm} = (\mathbf{D}_1\otimes\mathbf{I}_1) (\mathbf{I}_1 \otimes\mathbf{D}_1)\\ \hspace{0.8cm} = (\mathbf{D}_1\mathbf{I}_1)\otimes (\mathbf{I_1}\mathbf{D_1}) \\ \hspace{0.8cm} =\mathbf{D_1} \otimes \mathbf{D}_1\equiv\partial_{\eta \xi}$$

using the relation

$$(\mathbf{A} \otimes \mathbf{B})(\mathbf{C} \otimes \mathbf{D}) = (\mathbf{AC}) \otimes (\mathbf{BD})$$

Your second example can be derived in a similar way.