Frobenius inner product

In mathematics, the Frobenius inner product is a binary operation that takes two matrices and returns a scalar. It is often denoted $$\langle \mathbf{A},\mathbf{B} \rangle_\mathrm{F}$$. The operation is a component-wise inner product of two matrices as though they are vectors, and satisfies the axioms for an inner product. The two matrices must have the same dimension—same number of rows and columns—but are not restricted to be square matrices.

Definition
Given two complex-number-valued n×m matrices A and B, written explicitly as


 * $$ \mathbf {A} ={\begin{pmatrix}A_{11}&A_{12}&\cdots &A_{1m}\\A_{21}&A_{22}&\cdots &A_{2m}\\\vdots &\vdots &\ddots &\vdots \\A_{n1}&A_{n2}&\cdots &A_{nm}\\\end{pmatrix}} \,, \quad \mathbf {B} ={\begin{pmatrix}B_{11}&B_{12}&\cdots &B_{1m}\\B_{21}&B_{22}&\cdots &B_{2m}\\\vdots &\vdots &\ddots &\vdots \\B_{n1}&B_{n2}&\cdots &B_{nm}\\\end{pmatrix}},$$

the Frobenius inner product is defined as


 * $$\langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F} =\sum_{i,j}\overline{A_{ij}} B_{ij} \, = \mathrm{Tr}\left(\overline{\mathbf{A}^T} \mathbf{B}\right)

\equiv \mathrm{Tr}\left(\mathbf{A}^{\!\dagger} \mathbf{B}\right),$$

where the overline denotes the complex conjugate, and $$\dagger$$ denotes the Hermitian conjugate. Explicitly, this sum is


 * $$\begin{align} \langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F} = & \overline{A}_{11} B_{11} + \overline{A}_{12} B_{12} + \cdots + \overline{A}_{1m} B_{1m} \\

& + \overline{A}_{21} B_{21} + \overline{A}_{22} B_{22} + \cdots + \overline{A}_{2m} B_{2m} \\ & \vdots \\ & + \overline{A}_{n1} B_{n1} + \overline{A}_{n2} B_{n2} + \cdots + \overline{A}_{nm} B_{nm} \\ \end{align}$$

The calculation is very similar to the dot product, which in turn is an example of an inner product.

Relation to other products
If A and B are each real-valued matrices, then the Frobenius inner product is the sum of the entries of the Hadamard product. If the matrices are vectorized (i.e., converted into column vectors, denoted by "$$ \mathrm{vec}(\cdot) $$"), then


 * $$ \mathrm{vec}(\mathbf {A}) = {\begin{pmatrix} A_{11} \\ A_{12} \\ \vdots \\ A_{21} \\ A_{22} \\ \vdots \\ A_{nm} \end{pmatrix}},\quad \mathrm{vec}(\mathbf {B}) = {\begin{pmatrix} B_{11} \\ B_{12} \\ \vdots \\ B_{21} \\ B_{22} \\ \vdots \\ B_{nm} \end{pmatrix}} \,, $$$$ \quad \overline{\mathrm{vec}(\mathbf{A})}^T\mathrm{vec}(\mathbf {B}) = {\begin{pmatrix} \overline{A}_{11} & \overline{A}_{12} & \cdots & \overline{A}_{21} & \overline{A}_{22} & \cdots & \overline{A}_{nm} \end{pmatrix}} {\begin{pmatrix} B_{11} \\ B_{12} \\ \vdots \\ B_{21} \\ B_{22} \\ \vdots \\ B_{nm} \end{pmatrix}} $$

Therefore


 * $$ \langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F} = \overline{\mathrm{vec}(\mathbf{A})}^T \mathrm{vec}(\mathbf{B}) \, . $$

Properties
Like any inner product, it is a sesquilinear form, for four complex-valued matrices A, B, C, D, and two complex numbers a and b:


 * $$\langle a\mathbf{A}, b\mathbf{B} \rangle_\mathrm{F} = \overline{a}b\langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F} $$
 * $$\langle \mathbf{A}+\mathbf{C}, \mathbf{B} + \mathbf{D} \rangle_\mathrm{F} = \langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F} + \langle \mathbf{A}, \mathbf{D} \rangle_\mathrm{F} + \langle \mathbf{C}, \mathbf{B} \rangle_\mathrm{F} + \langle \mathbf{C}, \mathbf{D} \rangle_\mathrm{F} $$

Also, exchanging the matrices amounts to complex conjugation:


 * $$\langle \mathbf{B}, \mathbf{A} \rangle_\mathrm{F} = \overline{\langle \mathbf{A}, \mathbf{B} \rangle_\mathrm{F}} $$

For the same matrix,


 * $$\langle \mathbf{A}, \mathbf{A} \rangle_\mathrm{F} \geq 0$$,

and,
 * $$\langle \mathbf{A}, \mathbf{A} \rangle_\mathrm{F} = 0 \Longleftrightarrow \mathbf{A} = \mathbf{0}$$.

Frobenius norm
The inner product induces the Frobenius norm


 * $$\|\mathbf{A}\|_\mathrm{F} = \sqrt{\langle \mathbf{A}, \mathbf{A} \rangle_\mathrm{F}} \,.$$

Real-valued matrices
For two real-valued matrices, if


 * $$\mathbf{A} = \begin{pmatrix} 2 & 0 & 6 \\ 1 & -1 & 2 \end{pmatrix} \,,\quad \mathbf{B} = \begin{pmatrix} 8 & -3 & 2 \\ 4 & 1 & -5 \end{pmatrix}, $$

then


 * $$\begin{align}\langle \mathbf{A} ,\mathbf{B}\rangle_\mathrm{F} & = 2\cdot 8 + 0\cdot (-3) + 6\cdot 2 + 1\cdot 4 + (-1)\cdot 1 + 2\cdot(-5) \\

& = 21. \end{align} $$

Complex-valued matrices
For two complex-valued matrices, if


 * $$\mathbf{A} = \begin{pmatrix} 1+i & -2i \\ 3 & -5 \end{pmatrix} \,,\quad \mathbf{B} = \begin{pmatrix} -2 & 3i \\ 4-3i & 6 \end{pmatrix}, $$

then


 * $$\begin{align} \langle \mathbf{A} ,\mathbf{B}\rangle_\mathrm{F} & = (1-i)\cdot (-2) + 2i\cdot 3i + 3\cdot (4-3i) + (-5)\cdot 6 \\

& = -26 -7i, \end{align} $$

while


 * $$\begin{align} \langle \mathbf{B} ,\mathbf{A}\rangle_\mathrm{F} & = (-2)\cdot (1+i) + (-3i)\cdot (-2i) + (4+3i)\cdot 3 + 6 \cdot (-5) \\

& = -26 + 7i. \end{align} $$

The Frobenius inner products of A with itself, and B with itself, are respectively


 * $$\langle \mathbf{A}, \mathbf{A} \rangle_\mathrm{F} = 2 + 4 + 9 + 25 = 40 $$$$\qquad \langle \mathbf{B}, \mathbf{B} \rangle_\mathrm{F} = 4 + 9 + 25 + 36 = 74. $$