Tutorials › Linear Algebra › The Frobenius Inner Product On Matrices

Inner Products and Norms · Tutorial 599 of 1000

The Frobenius Inner Product On Matrices

Learn to compute the Frobenius inner product of real matrices and use it to find their induced lengths.

Intermediate 9 min read

What You'll Learn

  • Define the Frobenius inner product on a space of real matrices
  • Compute the inner product by multiplying corresponding entries and summing
  • Verify that the Frobenius formula satisfies the real inner product axioms
  • Relate the entrywise calculation to the trace of a matrix product
  • Find the length induced by the Frobenius inner product
  • Recognize when two matrices are orthogonal under this inner product

Comparing Matrices Entry by Entry

Vectors in \(\mathbb{R}^n\) can be compared with the standard dot product by multiplying corresponding coordinates and adding. A matrix also has coordinates: its entries. For two matrices of the same size, the Frobenius inner product applies exactly this idea to all their entries. It gives a real number, and it makes the space of matrices a real inner product space.

Let \(m,n\in\mathbb{N}\). The space \(\mathbb{R}^{m\times n}\) consists of all real matrices with \(m\) rows and \(n\) columns; addition and scalar multiplication are performed entry by entry. If \(\mathbf{A}=[a_{ij}]\) and \(\mathbf{B}=[b_{ij}]\) belong to this space, then they have matching entries in every position. The Frobenius inner product is defined by multiplying those matching entries and summing over all positions.

Definition: For \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{m\times n}\), their Frobenius inner product is \(\langle\mathbf{A},\mathbf{B}\rangle_F=\sum_{i=1}^{m}\sum_{j=1}^{n}a_{ij}b_{ij}\). The subscript \(F\) identifies this particular inner product. It is defined for matrices of the same size; matrices of different sizes do not belong to the same \(\mathbb{R}^{m\times n}\), so this formula does not define their Frobenius inner product.

The order of the two sums is not important, because there are only finitely many terms. A useful way to organize the calculation is to multiply corresponding entries row by row, then add the products. This operation is not matrix multiplication: it does not combine rows of one matrix with columns of another. It produces a scalar, not a matrix.

Computing the Inner Product

Worked Example: Two Square Matrices

Let \(\mathbf{A}=\begin{bmatrix}1&-2\\3&0\end{bmatrix}\) and \(\mathbf{B}=\begin{bmatrix}4&1\\-1&2\end{bmatrix}\). Compute their Frobenius inner product.

Multiply entries in matching positions, then add all four products:

$$ \begin{aligned} \langle\mathbf{A},\mathbf{B}\rangle_F &=1(4)+(-2)(1)+3(-1)+0(2)\\ &=4-2-3+0\\ &=-1. \end{aligned} $$

Check by the trace formula. The transpose of \(\mathbf{A}\) is \(\mathbf{A}^{\top}=\begin{bmatrix}1&3\\-2&0\end{bmatrix}\), so

$$ \mathbf{A}^{\top}\mathbf{B} = \begin{bmatrix}1&3\\-2&0\end{bmatrix} \begin{bmatrix}4&1\\-1&2\end{bmatrix} = \begin{bmatrix}1&7\\-8&-2\end{bmatrix}. $$

The trace, which is the sum of the diagonal entries, is \(1+(-2)=-1\). It agrees with the entrywise computation.

Rectangular matrices work in the same way. Every entry contributes once, regardless of its row or column. In particular, the number of rows need not equal the number of columns; only the sizes of the two matrices being compared must match.

Worked Example: Rectangular Matrices

Compute the Frobenius inner product of \(\mathbf{C}=\begin{bmatrix}1&0&-2\\3&1&2\end{bmatrix}\) and \(\mathbf{D}=\begin{bmatrix}2&-1&1\\0&4&-3\end{bmatrix}\). Both matrices are \(2\times3\).

List the six products in their matrix positions:

$$ \begin{aligned} \langle\mathbf{C},\mathbf{D}\rangle_F &=1(2)+0(-1)+(-2)(1)+3(0)+1(4)+2(-3)\\ &=2+0-2+0+4-6\\ &=-2. \end{aligned} $$

Check by grouping the same terms by columns. The first-column products sum to \(1(2)+3(0)=2\); the second-column products sum to \(0(-1)+1(4)=4\); and the third-column products sum to \((-2)(1)+2(-3)=-8\). Their total is \(2+4-8=-2\), as before.

Why This Formula Is an Inner Product

An inner product on a real vector space must be symmetric, linear in each argument, and positive definite. Positive definite means that the inner product of any vector with itself is nonnegative and equals zero only for the zero vector. For matrices, the zero vector in \(\mathbb{R}^{m\times n}\) is the zero matrix \(\mathbf{O}\). The entrywise formula has all of these properties.

Theorem: For any positive integers \(m,n\), the Frobenius inner product makes \(\mathbb{R}^{m\times n}\) a real inner product space.

Proof. Let \(\mathbf{A}=[a_{ij}]\), \(\mathbf{B}=[b_{ij}]\), and \(\mathbf{C}=[c_{ij}]\) be in \(\mathbb{R}^{m\times n}\), and let \(r\in\mathbb{R}\). Since real multiplication is commutative, \(a_{ij}b_{ij}=b_{ij}a_{ij}\) for every position. Summing these equalities gives \(\langle\mathbf{A},\mathbf{B}\rangle_F=\langle\mathbf{B},\mathbf{A}\rangle_F\), proving symmetry.

For linearity in the first argument, the \((i,j)\) entry of \(\mathbf{A}+\mathbf{C}\) is \(a_{ij}+c_{ij}\), and the \((i,j)\) entry of \(r\mathbf{A}\) is \(ra_{ij}\). Therefore, using distributivity and factoring the scalar in the finite sums,

$$ \begin{aligned} \langle\mathbf{A}+\mathbf{C},\mathbf{B}\rangle_F &=\sum_{i=1}^{m}\sum_{j=1}^{n}(a_{ij}+c_{ij})b_{ij}\\ &=\langle\mathbf{A},\mathbf{B}\rangle_F+\langle\mathbf{C},\mathbf{B}\rangle_F,\\ \langle r\mathbf{A},\mathbf{B}\rangle_F &=\sum_{i=1}^{m}\sum_{j=1}^{n}(ra_{ij})b_{ij} =r\langle\mathbf{A},\mathbf{B}\rangle_F. \end{aligned} $$

Symmetry then gives linearity in the second argument as well: \(\langle\mathbf{A},\mathbf{B}+\mathbf{C}\rangle_F=\langle\mathbf{B}+\mathbf{C},\mathbf{A}\rangle_F=\langle\mathbf{B},\mathbf{A}\rangle_F+\langle\mathbf{C},\mathbf{A}\rangle_F=\langle\mathbf{A},\mathbf{B}\rangle_F+\langle\mathbf{A},\mathbf{C}\rangle_F\), and \(\langle\mathbf{A},r\mathbf{B}\rangle_F=\langle r\mathbf{B},\mathbf{A}\rangle_F=r\langle\mathbf{B},\mathbf{A}\rangle_F=r\langle\mathbf{A},\mathbf{B}\rangle_F\).

Finally, each \(a_{ij}\) is real, so \(a_{ij}^2\geq0\). Thus \(\langle\mathbf{A},\mathbf{A}\rangle_F=\sum_{i=1}^{m}\sum_{j=1}^{n}a_{ij}^2\geq0\). If \(\mathbf{A}=\mathbf{O}\), every entry is zero and this sum equals zero. Conversely, if the sum equals zero, none of its nonnegative terms can be positive; hence \(a_{ij}^2=0\) and \(a_{ij}=0\) at every position. This says \(\mathbf{A}=\mathbf{O}\), proving positive definiteness. All the real inner product axioms hold. \(\square\)

The Trace Viewpoint

The same calculation can be written using matrix multiplication and trace. For a square matrix, the trace is the sum of its diagonal entries. If \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{m\times n}\), then \(\mathbf{A}^{\top}\mathbf{B}\) is an \(n\times n\) matrix, so its trace is defined.

Proposition: For \(\mathbf{A},\mathbf{B}\in\mathbb{R}^{m\times n}\), \(\langle\mathbf{A},\mathbf{B}\rangle_F=\operatorname{tr}(\mathbf{A}^{\top}\mathbf{B})\).

Proof. The diagonal entry in position \(j\) of \(\mathbf{A}^{\top}\mathbf{B}\) is \(\sum_{i=1}^{m}a_{ij}b_{ij}\), by the definition of matrix multiplication. The trace sums these diagonal entries for \(j=1,\ldots,n\). Therefore

$$ \operatorname{tr}(\mathbf{A}^{\top}\mathbf{B}) =\sum_{j=1}^{n}\sum_{i=1}^{m}a_{ij}b_{ij} =\sum_{i=1}^{m}\sum_{j=1}^{n}a_{ij}b_{ij} =\langle\mathbf{A},\mathbf{B}\rangle_F. $$

The middle equality reorders a finite sum; it does not change any term. This proves the identity for every pair of real matrices of the stated size. \(\square\)

The identity is an alternative way to compute the same scalar, not a different inner product. In particular, it requires the transpose and product to have compatible sizes as above. When the matrices are small, the entrywise formula is often quickest; the trace expression can be useful when a problem already contains matrix products.

The Length Induced by the Inner Product

An inner product induces a length by taking the nonnegative square root of the inner product of an object with itself. For a real matrix, the resulting Frobenius length is the square root of the sum of the squares of all entries. This follows directly from substituting the same matrix into both arguments of the defining formula.

Definition: The Frobenius length of \(\mathbf{A}=[a_{ij}]\in\mathbb{R}^{m\times n}\), induced by the Frobenius inner product, is \(\|\mathbf{A}\|_F=\sqrt{\langle\mathbf{A},\mathbf{A}\rangle_F}=\sqrt{\sum_{i=1}^{m}\sum_{j=1}^{n}a_{ij}^2}\).

Worked Example: Finding an Induced Matrix Length

Let \(\mathbf{M}=\begin{bmatrix}2&-1&0\\1&3&-2\end{bmatrix}\). Find its Frobenius length.

First compute its inner product with itself, squaring each entry:

$$ \begin{aligned} \langle\mathbf{M},\mathbf{M}\rangle_F &=2^2+(-1)^2+0^2+1^2+3^2+(-2)^2\\ &=4+1+0+1+9+4\\ &=19. \end{aligned} $$

Taking the nonnegative square root gives \(\|\mathbf{M}\|_F=\sqrt{19}\). Check: squaring this length gives \((\sqrt{19})^2=19\), exactly the computed value of \(\langle\mathbf{M},\mathbf{M}\rangle_F\). Since \(\mathbf{M}\) has nonzero entries, its length is positive.

The formula resembles the Euclidean length of a vector because the entries of a matrix are its coordinates in the space \(\mathbb{R}^{m\times n}\). There are \(mn\) such coordinates. The formula does not depend on arranging those entries visually in rows or columns: each entry is squared once and included in the sum.

Orthogonality and a Common Calculation Error

Two matrices in the same \(\mathbb{R}^{m\times n}\) are orthogonal under the Frobenius inner product when their inner product is zero. Neither matrix needs to be the zero matrix. Orthogonality is a statement about the sum of all corresponding-entry products; individual products may be positive, negative, or zero.

Worked Example: Orthogonal Nonzero Matrices

Consider \(\mathbf{P}=\begin{bmatrix}1&2\\0&-1\end{bmatrix}\) and \(\mathbf{Q}=\begin{bmatrix}2&-1\\3&0\end{bmatrix}\). Both are nonzero \(2\times2\) matrices. Their Frobenius inner product is

$$ \begin{aligned} \langle\mathbf{P},\mathbf{Q}\rangle_F &=1(2)+2(-1)+0(3)+(-1)(0)\\ &=2-2+0+0\\ &=0. \end{aligned} $$

Thus \(\mathbf{P}\) and \(\mathbf{Q}\) are orthogonal under the Frobenius inner product. The cancellation between the first two products is part of why the total is zero.

Common mistake: using only the diagonal entries. For \(\mathbf{X}=\begin{bmatrix}1&2\\3&4\end{bmatrix}\) and \(\mathbf{Y}=\begin{bmatrix}5&6\\7&8\end{bmatrix}\), a wrong calculation keeps only the diagonal products and reports \(1(5)+4(8)=37\). This omits the off-diagonal positions. The correct calculation includes all four matching positions:

$$ \langle\mathbf{X},\mathbf{Y}\rangle_F =1(5)+2(6)+3(7)+4(8) =5+12+21+32 =70. $$

The trace calculation confirms the correction: \(\mathbf{X}^{\top}\mathbf{Y}=\begin{bmatrix}26&30\\38&44\end{bmatrix}\), whose trace is \(26+44=70\). The trace sums diagonal entries of the product \(\mathbf{X}^{\top}\mathbf{Y}\); it does not mean that only diagonal positions of the original matrices contribute to the Frobenius inner product.

What the Formula Lets You Compare

The Frobenius inner product gives a consistent way to compare two matrices of the same size. A positive result indicates that the corresponding entries contribute a positive total, a negative result indicates a negative total, and zero indicates orthogonality in this inner product. A single sign does not say that every pair of corresponding entries has that sign; the total may combine positive and negative terms.

For practical calculations, use the entrywise formula when the matrices are displayed and small. Check that their dimensions match, include every position exactly once, and keep track of negative entries before summing. For a length calculation, first compute \(\langle\mathbf{A},\mathbf{A}\rangle_F\), then take its nonnegative square root. The trace identity provides a second route for checking a result, provided the matrix product is formed with the correct dimensions.

Check Your Understanding

Use the entrywise definition first, and use the trace formula as a check where appropriate.

  1. Compute the Frobenius inner product of \(\begin{bmatrix}2&-1\\0&3\end{bmatrix}\) and \(\begin{bmatrix}1&4\\-2&1\end{bmatrix}\).
  2. Find the Frobenius length of \(\begin{bmatrix}1&-2&2\end{bmatrix}\).
  3. Are \(\begin{bmatrix}1&1\\2&0\end{bmatrix}\) and \(\begin{bmatrix}1&-1\\0&3\end{bmatrix}\) orthogonal under the Frobenius inner product?
  4. State why the Frobenius inner product is not defined by this formula for two matrices of different sizes.
  5. For matrices of the same size, explain why the trace of \(\mathbf{A}^{\top}\mathbf{B}\) includes contributions from every matching entry, not only diagonal entries of \(\mathbf{A}\) and \(\mathbf{B}\).

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon