Cramer's rule is a formula in linear algebra for solving a square system of linear equations whose coefficient matrix has a nonzero determinant. Each unknown is expressed as a ratio: the denominator is the determinant of the coefficient matrix, and the numerator is the determinant obtained by replacing the corresponding column with the right-hand-side vector. The rule is named after the Swiss mathematician Gabriel Cramer, who published it in 1750. It is useful for theoretical arguments, symbolic calculations, and small systems, although other methods are generally preferred for large numerical problems.
Statement
Consider a system of linear equations in unknowns, written in matrix form as
where is an matrix, is the unknown vector, and is the given right-hand side.
The entries may belong to any field, including the real numbers or complex numbers. Suppose that
For each , let be the matrix obtained from by replacing its -th column with , leaving all other columns unchanged. Then the system has a unique solution, given by
The replacement must be made in the column corresponding to the unknown being calculated. Replacing a row instead generally does not give the required formula for a system written as .
Two-variable formula and example
For the system
the coefficient determinant is
If , Cramer's rule gives
For example, consider
Here
The replacement determinants are
Consequently,
Proof by multilinearity
Write the columns of as . The equation means that is the linear combination
The determinant is a multilinear map of its columns, so
where the displayed in each summand occupies the -th position, and the other columns retain their original positions.
When , the determinant in that summand has two identical columns and is therefore zero. Only the term remains:
Dividing by the nonzero determinant gives Cramer's formula.
The existence and uniqueness of the solution follow from the equivalence between a nonzero determinant and the existence of an inverse matrix. The argument above then identifies each coordinate of that solution.
Geometric interpretation
When , the columns of form a basis of the coordinate vector space. Solving means finding the coordinates of in that basis.
Over the real numbers, a determinant represents oriented area in two dimensions, oriented volume in three dimensions, and the corresponding higher-dimensional quantity. Replacing by changes this oriented volume by the factor . Thus
Orientation is essential: using absolute volumes alone would lose the sign of the coordinate.
Singular systems
The usual rule does not apply when , because its denominator vanishes. Such a square system has either no solution or infinitely many solutions over the real or complex numbers.
The undivided identity
still holds whenever a solution exists. Therefore, if but at least one , the system is inconsistent.
The converse is false: if the coefficient determinant and all replacement determinants vanish, consistency is not guaranteed. For example,
Every replacement determinant is zero, but the second equation is .
The general consistency test uses matrix rank:
where is the augmented matrix. When this equality holds, the solution is unique precisely when the common rank equals the number of unknowns.
Computational cost and numerical behavior
Cramer's rule is an explicit formula, but that does not make it an efficient general-purpose algorithm.
Computing each determinant by direct expansion involves factorially growing work. Using elimination to evaluate each of the determinants independently reduces the total cost to arithmetic operations in big-O notation. By comparison, conventional Gaussian elimination or LU decomposition solves a dense square system in operations.
These costs describe particular implementations, not an unavoidable complexity of the determinant identity itself. Shared computations can reduce the work, but standard numerical solvers usually obtain the solution directly rather than evaluate separate determinant ratios.
In floating-point arithmetic, separately computed determinants may overflow, underflow, or suffer from cancellation. Dividing them can compound numerical errors. The numerical stability of a calculation depends on the implementation; it is not determined solely by the formula.
The sensitivity of the underlying system is a separate issue, described by its condition number. A small determinant by itself does not establish ill-conditioning, because determinant magnitude depends strongly on scaling. For example, , with nonzero real , has determinant but condition number in the Euclidean norm.
Applications and historical context
Cramer's rule is particularly useful when explicit dependence on coefficients matters. If the entries of and depend polynomially on parameters, the formula expresses each solution coordinate as a ratio of polynomials wherever . This makes it useful in symbolic algebra and in identifying parameter values at which a system ceases to have a unique solution.
For an invertible matrix with integer entries and an integer right-hand side, the rule shows that every solution coordinate is rational. If or , every solution coordinate is an integer.
Cramer presented the general rule in his 1750 treatise Introduction à l’analyse des lignes courbes algébriques, in connection with determining algebraic curves from given conditions. Related determinant-based formulas appeared earlier, including in Colin Maclaurin's posthumously published A Treatise of Algebra in 1748. The modern matrix formulation expresses the rule more compactly than these early presentations.