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 column vector of right-sides of the equations. It is named after Gabriel Cramer, who published the rule for an arbitrary number of unknowns in 1750,[1][2] although Colin Maclaurin also published special cases of the rule in 1748,[3] and possibly knew of it as early as 1729.[4][5][6]
Cramer's rule, implemented in a naive way, is computationally inefficient for systems of more than two or three equations.[7] In the case of n equations in n unknowns, it requires computation of n + 1 determinants, while Gaussian elimination produces the result with the same computational complexity as the computation of a single determinant.[8][9][verification needed] Cramer's rule can also be numerically unstable even for 2×2 systems.[10] However, Cramer's rule can be implemented with the same complexity as Gaussian elimination,[11][12] (consistently requires twice as many arithmetic operations and has the same numerical stability when the same permutation matrices are applied).