In linear algebra, Cramer's rule is an explicit formula for the solution of a system of linear equations with as many equations as unknowns, valid whenever the system has a unique solution. It expresses the solution in terms of the determinants of the (square) coefficient matrix and of matrices obtained from it by replacing one column by the vector of right hand sides of the equations. It is named after Gabriel Cramer (1704–1752), who published the rule for an arbitrary number of unknowns in 1750, although Colin Maclaurin also published special cases of the rule in 1748 (and possibly knew of it as early as 1729).
Cramer's rule is computationally very inefficient for systems of more than two or three equations; its asymptotic complexity is O(n·n!) compared to elimination methods that have polynomial time complexity. Cramer's rule is also numerically unstable even for 2×2 systems.
Consider a system of n linear equations for n unknowns, represented in matrix multiplication form as follows:
where the n × n matrix A has a nonzero determinant, and the vector is the column vector of the variables. Then the theorem states that in this case the system has a unique solution, whose individual values for the unknowns are given by: