Ma · Mathematics

Why Is a Matrix Transpose Times Itself a Scalar?

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the dimensions

    For an m by n matrix A, A transpose times A has size n by n.

  2. 2. Recognize the vector case

    If A is a column vector, its transpose times itself is a 1 by 1 matrix, identified with a scalar.

  3. 3. Compute the entries

    Each entry of A transpose A is the dot product of a pair of columns of A.

  4. 4. Distinguish the norm

    The sum of squared entries is the trace of A transpose A, not generally the matrix itself.

Advertisement

The product of a matrix and its transpose is not always a scalar. The key is the matrix’s shape: a vector is a special kind of matrix, and the product of a vector with its transpose can be a scalar depending on whether the vector is written as a column or a row.

For a general matrix, ATAA^T A is a square matrix. Its entries are dot products between the columns of AA. The distinction also explains why the scalar length-squared of a matrix is usually written as a trace or a sum of squares.

Check the dimensions first

If AA has mm rows and nn columns, then its transpose ATA^T has nn rows and mm columns. Matrix multiplication gives

ATAwith dimensions(n×m)(m×n)=n×n.A^T A \quad \text{with dimensions} \quad (n\times m)(m\times n)=n\times n.

So the product is an nn-by-nn matrix. It is literally a scalar only when n=1n=1, meaning that AA has one column. A 1-by-1 matrix is conventionally identified with its single entry, a scalar.

Why the vector case gives a scalar

Write a column vector as

v=[v1v2⋮vm].v=\begin{bmatrix}v_1\\v_2\\\vdots\\v_m\end{bmatrix}.

Then vTv^T is a row vector, so the product has size 11-by-11:

vTv=[v1v2⋯vm][v1v2⋮vm]=v12+v22+⋯+vm2.v^T v=\begin{bmatrix}v_1&v_2&\cdots&v_m\end{bmatrix} \begin{bmatrix}v_1\\v_2\\\vdots\\v_m\end{bmatrix} =v_1^2+v_2^2+\cdots+v_m^2.

That sum is the dot product of vv with itself, also written ⟨v,v⟩\langle v,v\rangle, and equals the squared Euclidean length ∥v∥2\|v\|^2.

For example, if

v=[34],vTv=[34][34]=9+16=25.v=\begin{bmatrix}3\\4\end{bmatrix}, \qquad v^T v=\begin{bmatrix}3&4\end{bmatrix}\begin{bmatrix}3\\4\end{bmatrix}=9+16=25.

The length of vv is therefore 25=5\sqrt{25}=5.

What happens for a general matrix

Let AA have columns a1,a2,…,ana_1,a_2,\ldots,a_n. Then

ATA=[a1Ta1a1Ta2⋯a1Tana2Ta1a2Ta2⋯a2Tan⋮⋮⋱⋮anTa1anTa2⋯anTan].A^T A= \begin{bmatrix} a_1^T a_1 & a_1^T a_2 & \cdots & a_1^T a_n\\ a_2^T a_1 & a_2^T a_2 & \cdots & a_2^T a_n\\ \vdots & \vdots & \ddots & \vdots\\ a_n^T a_1 & a_n^T a_2 & \cdots & a_n^T a_n \end{bmatrix}.

Each entry is a scalar dot product, but all the entries together form an nn-by-nn matrix. This is called the Gram matrix of the columns of AA. Its diagonal entries are the squared lengths of the columns; its off-diagonal entries measure how the columns pair with one another.

For a concrete example, take

A=[1234].A=\begin{bmatrix}1&2\\3&4\end{bmatrix}.

Its columns are a1=(1,3)Ta_1=(1,3)^T and a2=(2,4)Ta_2=(2,4)^T. Their dot products are a1Ta1=10a_1^T a_1=10, a1Ta2=14a_1^T a_2=14, and a2Ta2=20a_2^T a_2=20. Thus

ATA=[10141420],A^T A=\begin{bmatrix}10&14\\14&20\end{bmatrix},

which is a matrix, not a scalar. The individual entries are scalars, but the product itself has four entries.

For a real matrix AA, the trace of ATAA^T A is a scalar:

tr⁡(ATA)=∑i=1m∑j=1nAij2.\operatorname{tr}(A^T A)=\sum_{i=1}^{m}\sum_{j=1}^{n} A_{ij}^2.

This is the squared Frobenius norm, ∥A∥F2\|A\|_F^2. In the example above, it is 10+20=3010+20=30, also the sum 12+22+32+421^2+2^2+3^2+4^2. This scalar is not the same thing as the matrix ATAA^T A.

Common mistakes

  • Ignoring the shape of a vector. A column vector vv gives scalar vTvv^T v. A row vector rr gives scalar rrTr r^T. Reversing either product gives a matrix: vvTv v^T or rTrr^T r.
  • Calling every entry the whole product. The entries of ATAA^T A are scalars, but for a matrix with multiple columns, the full product is still a matrix.
  • Confusing a scalar matrix with a scalar. In special cases, ATA=λIA^T A=\lambda I for a scalar λ\lambda. The left side is still an nn-by-nn matrix; it is a scalar multiple of the identity. This occurs when the columns of AA are mutually orthogonal and all have the same length.
  • Using transpose for complex vectors. For complex entries, the corresponding inner product uses the conjugate transpose A∗A^*, not just ATA^T. Then A∗AA^*A is a Gram matrix, and for a column vector vv, v∗v=∑i∣vi∣2v^*v=\sum_i |v_i|^2.

When in doubt, check the dimensions before interpreting the product: they tell you whether the result is a scalar, a vector, or a matrix.

References

  1. Linear Algebra and Its Applications

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.