# How to calculate the divergence of matrix?

The divergence of a vector field in Cartesian coordinate system (CCS) is defined as follows

$$\mathrm{div}(\mathbf v) = \nabla \cdot \mathbf v = \begin{bmatrix} \frac{\partial}{\partial x} \\ \frac{\partial}{\partial y} \\ \frac{\partial}{\partial z} \end{bmatrix} \cdot \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} = \begin{bmatrix} \frac{\partial}{\partial x} \\ \frac{\partial}{\partial y} \\ \frac{\partial}{\partial z} \end{bmatrix}^T \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} = \begin{bmatrix} \frac{\partial}{\partial x} & \frac{\partial}{\partial y} & \frac{\partial}{\partial z} \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} =\frac{\partial v_1}{\partial x}+ \frac{\partial v_2}{\partial y}+ \frac{\partial v_3}{\partial z}$$

where $$\cdot$$ denotes the dot product; it was changed to transposition with matrix multiplication. Now lets define some matrix

$$A = \begin{bmatrix} a_{11} && a_{12} && a_{13} \\ a_{21} && a_{22} && a_{23} \\ a_{31} && a_{32} && a_{33} \\ \end{bmatrix}$$

How to calculate divergence of matrix in CCS and how looks its 'dot' product and 'matrix multiplication' form?

$$\mathrm{div}(A) = ?$$

• as far I know, the divergence of matrix should give vector as a result – Kamil Kiełczewski Dec 30 '19 at 17:04
• This might help – A. Goodier Dec 30 '19 at 17:04
• @mvpq thank for link, but someone told there in comments that forumla given in wiki is WRONG (idex-es are bad) – Kamil Kiełczewski Dec 30 '19 at 17:06
• First calculate the gradient $\;g_{ij}=\partial_iv_j\;$ then calculate the divergence by contracting over the leading two indices, i.e. $\;\phi=\delta_{ij}g_{ij}=g_{ii}.\;$ This procedure can be extended to arbitrary tensors, just add more indices on the right, e.g. \eqalign{g_{ijklm}&=\partial_iv_{jklm}\\ \phi_{klm}&=\delta_{ij}g_{ijklm}=g_{iiklm}} – greg Dec 30 '19 at 18:14
• @greg in your approach (for 3x3 matrix) the div(A) will give scalar (if I read your formulas in good way) - but as far I know, the div(A) should give VECTOR as result – Kamil Kiełczewski Dec 30 '19 at 18:21

In this answer I use $$x=x_1, y=x_2, z=x_3$$ and Einstein notation. On wikipedia in this article I found following information (in article they use S instead A) for CCS:

$$\nabla\cdot A = \cfrac{\partial A_{ki}}{\partial x_k}~\mathbf{e}_i = A_{ki,k}~\mathbf{e}_i = \begin{bmatrix} \frac{\partial a_{11}}{\partial x} + \frac{\partial a_{21}}{\partial y} + \frac{\partial a_{31}}{\partial z} \\ \frac{\partial a_{12}}{\partial x} + \frac{\partial a_{22}}{\partial y} + \frac{\partial a_{32}}{\partial z} \\ \frac{\partial a_{13}}{\partial x} + \frac{\partial a_{23}}{\partial y} + \frac{\partial a_{33}}{\partial z} \\ \end{bmatrix}$$

The result is contravariant (column) vector. But in this article is mention that $$\mathrm{div}(A) \neq \nabla\cdot A$$ and

$$\mathrm{div}(A) = \nabla\cdot A^T = \cfrac{\partial A_{ik}}{\partial x_k}~\mathbf{e}_i = A_{ik,k}~\mathbf{e}_i = \begin{bmatrix} \frac{\partial a_{11}}{\partial x} + \frac{\partial a_{12}}{\partial y} + \frac{\partial a_{13}}{\partial z} \\ \frac{\partial a_{21}}{\partial x} + \frac{\partial a_{22}}{\partial y} + \frac{\partial a_{23}}{\partial z} \\ \frac{\partial a_{31}}{\partial x} + \frac{\partial a_{32}}{\partial y} + \frac{\partial a_{33}}{\partial z} \\ \end{bmatrix}$$

When A is symetric: $$a_{ij}=a_{ji}$$ then $$\mathrm{div}(A) = \nabla\cdot A$$

Wiki also mention that some authors use alternative definition: $$\nabla\cdot A = \cfrac{\partial A_{ik}}{\partial x_k}~\mathbf{e}_i$$ probably only for case when A is symmetric (for which that alternative definition is equal to original). However alternative definition is NOT compatible with general curvilinear definition which I found on wiki too:

$$\nabla\cdot A = \left(\cfrac{\partial A_{ki}}{\partial x_k}- A_{li}~\Gamma_{kk}^l - A_{kl}~\Gamma_{ki}^l\right)~\mathbf{g}^i$$

• currently I don't know what is exact definition of: $\mathbf{g}^i$ - probably it will give something like $\mathbf{e}_i$ (?) – Kamil Kiełczewski Dec 31 '19 at 10:50