TL;DR
A square root of a matrix is a matrix such that times equals , just as 3 is a square root of 9 because . When is a symmetric matrix whose eigenvalues are all positive, there is exactly one square root that is also symmetric with positive eigenvalues. You build it by taking the ordinary square root of each eigenvalue. It matters when a problem is stated in matrix form and needs a "half step" of a matrix, such as shaping random noise to match a covariance matrix or comparing two clouds of data.
Builds on: Symmetric Matrix, Positive Definite Matrix, Eigenvalues and Eigenvectors, Matrix Multiplication · Leads to: Fréchet Inception Distance
Where it's used
Judging image generators. The Fréchet Inception Distance (FID) scores generated pictures by comparing the mean and covariance of network features computed on real images and on generated ones. Its formula contains the square root of a product of two covariance matrices. Each one is a square table with 2048 rows and columns, estimated from tens of thousands of images. Every FID score depends on this matrix square root.
Generating correlated random numbers. To make a random vector with covariance , you multiply a matrix with by a vector of independent standard normal numbers. Simulators in finance and physics use this to create correlated shocks. Cholesky decomposition does the same job more cheaply, so the symmetric square root is chosen only when the symmetry itself matters.
Comparing quantum states. The fidelity between two quantum states is defined using square roots of their density matrices, which are symmetric positive matrices. Physicists compute these roots to measure how easily one state can be told apart from another.
How it works
Take the symmetric matrix
We want a matrix with .
-
Check the conditions. The entry in row 1, column 2 is 4, and the entry in row 2, column 1 is also 4. Swapping rows and columns leaves unchanged, so is symmetric. Check: the matrix has no hidden asymmetry.
-
Find the eigenvalues, the stretch factors for which has a nonzero solution . The eigenvalues add up to the trace and multiply to the determinant . The pair that does both is 9 and 1. Check: and .
-
Find an eigenvector for each eigenvalue. For , the vector works, because . For , the vector works, because .
-
Scale each eigenvector to length 1. Both have length , so the unit vectors are and . They are at right angles, so placed side by side as columns they form an orthogonal matrix . Check: the dot product of and is .
-
Take the ordinary square root of each eigenvalue: and . Put them on the diagonal of a diagonal matrix, . Check: squaring each diagonal entry gives back 9 and 1.
-
Rebuild the matrix from these pieces: . Multiplying out gives
Check: each diagonal entry is the average of the two roots, .
-
Square to confirm. The (1,1) entry is and the (1,2) entry is . Both match .
The steps form a pipeline. The matrix only stretches along a few perpendicular directions, and the square root takes the root of each stretch while keeping the directions the same.
flowchart LR A["A: symmetric, positive eigenvalues"] --> E["eigenvalues and unit eigenvectors"] E --> R["square root of each eigenvalue"] R --> S["S = Q times sqrt(Lambda) times Q-transpose"]
The math
Let be a symmetric matrix whose eigenvalues are all positive, such a matrix is called positive definite. Its principal square root is the unique symmetric matrix with all positive eigenvalues and .
Step 4 in symbols: the spectral decomposition
Because is symmetric, its eigenvectors can be chosen at right angles and scaled to length 1. Stacking them as the columns of gives
Here is the transpose of , the matrix with rows and columns swapped. Check with the example: with , the product gives back .
Step 5 in symbols: the square root
Define
Then
The middle pair equals the identity matrix because the columns of are unit vectors at right angles. Then , since each diagonal entry is .
For one number, this is the usual square root. The plot shows at the eigenvalues 1, 4 and 9.
- square root
Worked examples
Let .
- is already diagonal, so its eigenvectors are the coordinate axes and , and .
- The eigenvalues are the diagonal entries, 4 and 9.
- Their square roots are 2 and 3.
- So .
- Check: .
Interpretation: when a matrix only stretches along the axes, its square root takes the root of each stretch.
Let .
- is symmetric, since the off-diagonal entries are both 1.
- The trace is 4 and the determinant is . The eigenvalues are 3 and 1, because and .
- Eigenvectors: , so belongs to 3. And , so belongs to 1.
- Unit eigenvectors give .
- The roots of the eigenvalues are and 1.
- Then .
- Check: the (1,1) entry of is , and the (1,2) entry is . Both match .
Interpretation: the root mixes the two coordinate directions in the same way the original matrix does. It is not the matrix of square roots of the entries, which we check in the common mistakes section.
Let the covariance be . We want with , so that has covariance when has independent standard normal entries.
- is symmetric. Its trace is 7 and its determinant is , so the eigenvalues are 6 and 1, since and .
- For 6, the eigenvector works: . For 1, the eigenvector works: . Scaling to unit length gives and .
- The roots of the eigenvalues are and 1.
- Combine the two rank-one pieces: .
- Numerically, .
- Check the first variance: the (1,1) entry of is , which rounds to the 5 in .
Interpretation: multiplying independent noise by produces a pair whose first coordinate has variance 5, second has variance 2, and whose coordinates are correlated.
Try it: using the same , the (2,2) entry of should equal the (2,2) entry of . Compute . Answer: , which matches the 2 in .
Common mistakes and tradeoffs
It is tempting to think the square root of a matrix is the matrix of square roots of its entries. In fact it is not, because multiplying matrices mixes entries together. The entrywise root of is , and squaring it gives , not the original matrix.
It is tempting to think a matrix has only one square root. In fact the identity matrix has many, including and and . The symmetric root with positive eigenvalues is unique, and that is what "principal" means.
It is tempting to think every matrix has a square root. In fact has none. If , then , so is nilpotent. A nilpotent matrix squares to zero, so , which contradicts .
Use the symmetric square root when the symmetry matters, for example when the same covariance must be matched in any rotated coordinate system. Use Cholesky decomposition when you only need some matrix with , such as to generate samples. It is cheaper and produces a triangular matrix, which is easy to work with. For a matrix that is not symmetric or not square, the singular value decomposition is the right tool instead.
History
Matrix roots were studied soon after matrices themselves. Arthur Cayley's 1858 memoir on matrices discussed square roots, especially for matrices. The eigenvalue methods used here were developed over the nineteenth century, when people studied quadratic forms. For large matrices, computing a square root directly was impractical until computers made numerical methods possible. The Schur-based method of Björck and Hammarling, published in 1983, became a standard general algorithm. The idea reached machine learning in 2017, when the Fréchet Inception Distance used the matrix square root to compare image-feature distributions.
Recap
- A square root of satisfies .
- For a symmetric matrix with positive eigenvalues, the principal square root is unique.
- The recipe: find the eigenvalues and orthonormal eigenvectors, take the square root of each eigenvalue, and rebuild .
- The root is what makes correlated noise with a given covariance possible.
- Read next: the Fréchet Inception Distance, which uses the square root of a product of covariance matrices.
Check yourself
QuestionWhat does it mean for a matrix to be a square root of ?Show answer
It means . Multiplying by itself, using matrix multiplication, returns .
QuestionFor , the principal square root is . What is the (1,2) entry of ?Show answer
It is 1. The (1,2) entry of is , which is the (1,2) entry of , so the root is correct.
QuestionWhy is the matrix of entrywise square roots not the square root of ?Show answer
Matrix squaring combines entries across rows and columns; it does not square each entry separately. Squaring the entrywise root gives , which is not the original matrix. The square root must be built from eigenvalues and eigenvectors.
QuestionA colleague says the Cholesky factor and the symmetric square root both produce samples with covariance . Is this right, and which is cheaper?Show answer
Yes. If has independent standard normal entries, then has covariance , and has covariance . Cholesky is cheaper, because it is computed directly from the entries of without finding eigenvalues, and is triangular.