Advanced maths

Generalized singular value decomposition calculator for a matrix pair

Construct a thin generalized singular value decomposition of two real full-column-rank matrices sharing a column dimension.

Your numbers

One row per matrix row or sequence observation, comma-separated entries.
One row per matrix row or sequence observation, comma-separated entries.

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

Construct a thin generalized singular value decomposition of two real full-column-rank matrices sharing a column dimension.

THE FORMULAA=U diag(c)X⁻¹; B=V diag(s)X⁻¹; UᵀU=VᵀV=I; c²+s²=1.

A worked example

For A columns scaled 1,2 and B columns scaled 2,1, generalized singular values are 0.5 and 2; their cosine/sine pairs satisfy c²+s²=1.

Good to know

2–4 shared columns, each matrix between n and 6 rows, both full column rank and a well-conditioned positive stack Gramian. Thin GSVD under the stated right-basis convention; repeated values permit nonunique bases; rank-deficient cases rejected.

Comparing two rectangular operators

The generalized singular value decomposition factors two matrices that act on the same input-coordinate space. Their row counts can differ, but their columns must correspond to the same unknown vector. The factors expose directions where one operator is strong relative to the other.

This differs from an ordinary SVD of one matrix or generalized eigenvalues of a square matrix pencil. Those tools can help compute a GSVD, but do not by themselves return the two rectangular orthonormal left factors and common invertible right basis required by this page's decomposition.

Paired column strengthsRatios: 0.5, 2c² + s² = 1A = U diag(c) X⁻¹
Scroll across to see the full diagram.
The two default input directions have A/B strength ratios 0.5 and 2.

Compare this with the Generalized eigenvalue calculator for a matrix pair. Simultaneously factor two rectangular matrices sharing columns into GSVD factors; a square eigenvalue pencil does not give this rectangular decomposition.

The supported thin convention

The returned convention is A equals U times diagonal c times X inverse, and B equals V times diagonal s times X inverse. The columns of U and V are orthonormal, while X is generally not orthogonal. Each cosine-sine pair satisfies c squared plus s squared equal to one.

Both input matrices must have full column rank in this implementation. Their shared column count is between two and four, with at least that many rows in each. Broader GSVD definitions handle rank-deficient stacks and zero or infinite generalized singular values, but this bounded interface deliberately rejects those cases.

The diagonal-scale worked example

The default first matrix has orthogonal columns with lengths one and two. The second has corresponding column lengths two and one. Their generalized singular values are therefore one-half and two, measuring the relative response along those two input directions.

The corresponding cosine-sine pairs are one over square root of five with two over square root of five, and the reversed pair. All four scalar entries are finite and positive. Different common scaling of the input-coordinate basis can change X while leaving the complete reconstruction identities intact.

Whitening the stacked column geometry

The combined Gramian is A transpose A plus B transpose B. Its positive inverse square root supplies a common whitening map. After whitening, the two Gram matrices sum to identity, so diagonalizing one also diagonalizes the other through complementary eigenvalues.

The implementation uses those eigenvectors to construct X, then normalizes the transformed A and B columns into U and V. This is a small dense construction suitable for the declared well-conditioned dimensions, not a claim to replace every rank-revealing feature of a production LAPACK GSVD driver.

Checking reconstruction and orthogonality

The calculator multiplies the returned factors back together and measures their discrepancy from both input matrices. It also checks U transpose U and V transpose V against identity. These residuals test the full factors rather than only comparing the generalized singular values.

The right basis must be used with the stated inverse. Software packages differ in whether they report a transposed orthogonal matrix, a triangular common factor or an inverse right factor. Copying a matrix named X from one convention into another expression can fail even if both decompositions are mathematically correct.

Repeated values and numerical rank

Repeated generalized singular values allow rotations within their shared invariant subspace. Individual vectors are then nonunique, so another valid implementation need not print the same columns. Reconstruction, orthogonality and the set of generalized values are the appropriate comparisons.

Near a zero sine or cosine, the normalization becomes ill-conditioned and the ratio can be very large or small. This page rejects unresolved rank boundaries rather than presenting unstable factors with a false accuracy claim. Rescaling columns consistently across both matrices may help conditioning without changing the underlying paired task.

Using the factors in a larger problem

GSVD directions can clarify regularization or the competing effects of two operators. They do not select a regularization weight, infer noise levels or establish a causal interpretation of columns. Those choices belong to the surrounding inverse problem and remain external to this calculation.

Preserve row units and common column meaning when preparing matrices. Independently scaling one operator changes the comparison and therefore its generalized values. For rank-deficient or large problems, use a dedicated decomposition routine with explicit rank and zero-value conventions rather than forcing the data into this smaller supported domain.

A few questions, answered

Must both matrices have the same rows?

No. They share columns, but their row counts may differ within the supported bounds.

Is X orthogonal?

Generally no. It is a common invertible right basis under the stated thin-factor convention.

Why can another implementation return different vectors?

Signs, ordering and rotations within repeated-value subspaces are nonunique.

Are zero or infinite generalized singular values supported?

No. This implementation requires both matrices to have full column rank.

Find your calculator

Start typing to explore the library.