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.
[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).
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
Then the theorem states that in this case the system has a unique solution, whose individual values for the unknowns are given by: where
The rule holds for systems of equations with coefficients and unknowns in any field, not just in the real numbers.
The proof for Cramer's rule uses the following properties of the determinants: linearity with respect to any given column and the fact that the determinant is zero whenever two columns are equal, which is implied by the property that the sign of the determinant flips if you switch two columns.
This makes the determinant a function of the entries of the jth column.
Linearity with respect of this column means that this function has the form where the
Now consider a system of n linear equations in n unknowns
as As, by construction, the numerator is the determinant of the matrix obtained from A by replacing column j by b, we get the expression of Cramer's rule as a necessary condition for a solution.
It remains to prove that these values for the unknowns form a solution.
show that one has MA = det(A)In, and therefore, This completes the proof, since a left inverse of a square matrix is also a right-inverse (see Invertible matrix theorem).
In fact, this formula works whenever F is a commutative ring, provided that det(A) is a unit.
Consider the linear system which in matrix format is Assume a1b2 − b1a2 is nonzero.
Given which in matrix format is Then the values of x, y and z can be found as follows: Cramer's rule is used in the Ricci calculus in various calculations involving the Christoffel symbols of the first and second kind.
[14] In particular, Cramer's rule can be used to prove that the divergence operator on a Riemannian manifold is invariant with respect to change of coordinates.
We give a direct proof, suppressing the role of the Christoffel symbols.
Writing this transformation law in terms of matrices yields
, it is necessary and sufficient to show that which is equivalent to Carrying out the differentiation on the left-hand side, we get: where
First, calculate the first derivatives of F, G, x, and y: Substituting dx, dy into dF and dG, we have: Since u, v are both independent, the coefficients of du, dv must be zero.
This makes the integer program substantially easier to solve.
Cramer's rule is used to derive the general solution to an inhomogeneous linear differential equation by the method of variation of parameters.
These geometric arguments work in general and not only in the case of two equations with two unknowns presented here.
A short proof of Cramer's rule [15] can be given by noticing that
For linear equations, an indeterminate system will have infinitely many solutions (if it is over an infinite field), since the solutions can be expressed in terms of one or more parameters that can take arbitrary values.
Cramer's rule applies to the case where the coefficient determinant is nonzero.