Advanced maths

Affine invariant geometric mean calculator for positive definite matrices

Compute the weighted affine-invariant geometric mean of two positive definite matrices using symmetric matrix powers.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Compute the weighted affine-invariant geometric mean of two positive definite matrices using symmetric matrix powers.

THE FORMULAA#_t B = A^(1/2) (A^(-1/2) B A^(-1/2))^t A^(1/2).

A worked example

At weight one-half, diagonal matrices diag(1,4) and diag(9,16) have geometric mean diag(3,8), determinant 24.

Good to know

Two real SPD matrices order2–5 and weight0–1. Symmetric spectral evaluation, positivity, congruence and endpoint checks; condition-number cap. No log-Euclidean mean substituted, singular PSD extension or statistical covariance-estimation promise.

A geometric mean that respects coordinates

Positive definite matrices can represent quadratic forms, covariance geometry or local metrics. Their affine-invariant geometric mean is a matrix lying on a particular positive-definite geodesic between two inputs. The weight chooses its position along that path, extending the scalar weighted geometric mean while preserving a meaningful behavior under invertible changes of coordinates.

This operation differs from averaging entries or multiplying the two matrices and taking an entrywise square root. Matrix multiplication need not commute, so apparently interchangeable scalar formulas can produce different matrix answers. The displayed construction uses symmetric positive-definite matrix powers and keeps the result in the same positive-definite family as the two inputs.

Affine invariant geometric mean calculator for positive definite matrices worked examplediag(1,4)Midpoint: diag(3,8)Other endpoint: diag(9,16)determinant at t=1/2: 24
Scroll across to see the full diagram.
At weight one-half, diagonal matrices diag(1,4) and diag(9,16) have geometric mean diag(3,8), determinant 24.

Compare this with the Principal matrix square root calculator with a reconstruction residual. Compute a binary SPD matrix mean and its weighted affine-invariant geodesic, rather than a unary matrix square root or elementwise average.

Checking symmetry and positive definiteness

Both inputs must be real symmetric matrices of the same supported order. Symmetry is checked before interpreting their eigenvalues as quadratic-form geometry. Every eigenvalue must be strictly positive and sufficiently resolved relative to the matrix scale. A singular positive semidefinite matrix lies outside this page's supported domain, even though some mathematical extensions exist.

A poorly conditioned input has a very small eigenvalue compared with its largest one. Forming inverse square roots then magnifies numerical error. The condition cap is a practical arithmetic limit, not a claim that the exact mean ceases to exist. A rejected ill-conditioned input should therefore be reported as unsupported or unresolved rather than declared mathematically nonpositive without evidence.

Whitening, powering and mapping back

First whiten the second matrix using the inverse square root of the first. This produces the symmetric positive-definite matrix A to the minus one half times B times A to the minus one half. Raise that whitened matrix to the requested real weight using its symmetric eigendecomposition, then map it back with A's positive square root on both sides.

This sequence preserves symmetry and specifies which square-root branch is intended. Ordinary products of nonsymmetric intermediate matrices can conceal avoidable loss of symmetry. The calculation should check the reconstructed result's positive eigenvalues and its numerical symmetry rather than assuming that any array produced by a generic power routine must be the desired geometric mean.

Understanding the weight

At weight zero, the result is the first matrix; at weight one, it is the second. At one half, it is the unweighted geometric midpoint. The page restricts the weight to the interval from zero through one so that the result is an interpolation. Extrapolation along the same mathematical geodesic is a separate requested behavior, not an accidental consequence of accepting any number.

Interchanging the two input matrices and replacing the weight by one minus itself gives the same mean. That relation is a useful check when the matrices do not commute. At the midpoint, the result solves X times inverse A times X equals B. This identity gives an additional independent numerical verification beyond merely repeating the same eigenvalue-power expression.

The diagonal worked example

The default first matrix is diagonal with entries one and four. The second is diagonal with entries nine and sixteen. Because they commute and share coordinate axes, the midpoint can be checked entry by entry: the square roots of one times nine and four times sixteen are three and eight. The resulting determinant is twenty-four.

This convenient simplification does not hold by multiplying arbitrary matrix entries when the input eigenspaces differ. A second test should therefore use a noncommuting pair. Applying the same invertible coordinate transformation to both inputs should transform the computed mean by the corresponding congruence, while preserving the chosen weight and the geometric interpretation of the quadratic forms.

Determinant and congruence checks

The determinant of the weighted mean equals determinant A to the power one minus the weight times determinant B to the power of the weight. Using logarithms can evaluate this identity without unnecessarily overflowing intermediate powers. It is a scalar diagnostic, so agreement does not establish every matrix entry; combine it with symmetry, positivity and reconstruction checks.

Affine invariance concerns congruence by an invertible coordinate matrix: transform A and B as C A C transpose and C B C transpose. Their mean must transform in the same way. This is not the same operation as an arbitrary similarity transformation. Confusing those two transformations can lead to a false invariance claim or an incorrectly designed validation test.

Interpreting the mean in applications

The geometric mean is one specified way to interpolate positive definite objects, not a universal estimator of a true covariance or a guarantee of statistical accuracy. Arithmetic, harmonic and log-Euclidean means answer different optimization or geometry questions. Choose the operation according to the model, and retain the input units and coordinate convention with the returned matrix.

The page does not estimate covariance from observations, choose a regularization strength or repair an indefinite matrix automatically. Adding a diagonal adjustment would change the inputs and should be a deliberate separate step. A successful result means the advertised positive-definite interpolation passed its numerical checks, not that the input matrices are well supported by any external data.

A few questions, answered

Is this the log-Euclidean mean?

No. The affine-invariant formula whitens by the first matrix and generally differs from exponentiating a weighted average of matrix logarithms.

Can I use singular covariance matrices?

This bounded implementation requires strictly positive definite matrices.

What happens at weights zero and one?

The result equals the first and second matrix respectively.

Can I take square roots entry by entry?

No. Matrix square roots use the symmetric spectral decomposition, not independent entrywise roots.

Find your calculator

Start typing to explore the library.