{
  "id": "cramers-rule",
  "title": "Cramer's Rule",
  "lang": "en",
  "source_lang": "en",
  "summary": "Cramer's rule expresses the unique solution of a square linear system with nonzero determinant as ratios of determinants.",
  "category": "mathematics",
  "subcategory": "algebra",
  "type": "concept",
  "aliases": [
    "Cramer’s formula",
    "Rule of Cramer"
  ],
  "generated_at": "2026-11-04",
  "model": "pro/gpt-6.1-sol",
  "url": "https://aiwiki.page/en/cramers-rule/",
  "translations": {
    "zh-Hans": {
      "url": "https://aiwiki.page/zh/cramers-rule/",
      "json": "https://aiwiki.page/zh/cramers-rule.json"
    }
  },
  "sections": [
    {
      "heading": "",
      "text": "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."
    },
    {
      "heading": "Statement",
      "text": "Consider a system of \\(n\\) linear equations in \\(n\\) unknowns, written in matrix form as\n\n\\[A\\mathbf{x}=\\mathbf{b},\\]\n\nwhere \\(A=(a_{ij})\\) is an \\(n\\times n\\) matrix, \\(\\mathbf{x}=(x_1,\\ldots,x_n)^{\\mathsf T}\\) is the unknown vector, and \\(\\mathbf{b}\\) is the given right-hand side.\n\nThe entries may belong to any field, including the real numbers or complex numbers. Suppose that\n\n\\[\\det(A)\\ne 0.\\]\n\nFor each \\(i\\), let \\(A_i\\) be the matrix obtained from \\(A\\) by replacing its \\(i\\)-th column with \\(\\mathbf{b}\\), leaving all other columns unchanged. Then the system has a unique solution, given by\n\n\\[\\boxed{x_i=\\frac{\\det(A_i)}{\\det(A)},\\qquad i=1,\\ldots,n.}\\]\n\nThe 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 \\(A\\mathbf{x}=\\mathbf{b}\\)."
    },
    {
      "heading": "Two-variable formula and example",
      "text": "For the system\n\n\\[\\begin{aligned} ax+by&=e,\\\\ cx+dy&=f, \\end{aligned}\\]\n\nthe coefficient determinant is\n\n\\[D= \\begin{vmatrix} a&b\\\\ c&d \\end{vmatrix} =ad-bc.\\]\n\nIf \\(D\\ne0\\), Cramer's rule gives\n\n\\[x= \\frac{ \\begin{vmatrix} e&b\\\\ f&d \\end{vmatrix} }{D} =\\frac{ed-bf}{ad-bc}, \\qquad y= \\frac{ \\begin{vmatrix} a&e\\\\ c&f \\end{vmatrix} }{D} =\\frac{af-ec}{ad-bc}.\\]\n\nFor example, consider\n\n\\[\\begin{aligned} 2x+y&=5,\\\\ x-y&=1. \\end{aligned}\\]\n\nHere\n\n\\[D= \\begin{vmatrix} 2&1\\\\ 1&-1 \\end{vmatrix} =-3.\\]\n\nThe replacement determinants are\n\n\\[D_x= \\begin{vmatrix} 5&1\\\\ 1&-1 \\end{vmatrix} =-6, \\qquad D_y= \\begin{vmatrix} 2&5\\\\ 1&1 \\end{vmatrix} =-3.\\]\n\nConsequently,\n\n\\[x=2,\\qquad y=1.\\]"
    },
    {
      "heading": "Proof by multilinearity",
      "text": "Write the columns of \\(A\\) as \\(\\mathbf{a}_1,\\ldots,\\mathbf{a}_n\\). The equation \\(A\\mathbf{x}=\\mathbf{b}\\) means that \\(\\mathbf{b}\\) is the linear combination\n\n\\[\\mathbf{b}=\\sum_{j=1}^{n}x_j\\mathbf{a}_j.\\]\n\nThe determinant is a multilinear map of its columns, so\n\n\\[\\begin{aligned} \\det(A_i) &=\\det(\\mathbf{a}_1,\\ldots,\\mathbf{b},\\ldots,\\mathbf{a}_n)\\\\ &=\\sum_{j=1}^{n} x_j\\det(\\mathbf{a}_1,\\ldots,\\mathbf{a}_j,\\ldots,\\mathbf{a}_n), \\end{aligned}\\]\n\nwhere the displayed \\(\\mathbf{a}_j\\) in each summand occupies the \\(i\\)-th position, and the other columns retain their original positions.\n\nWhen \\(j\\ne i\\), the determinant in that summand has two identical columns and is therefore zero. Only the term \\(j=i\\) remains:\n\n\\[\\det(A_i)=x_i\\det(A).\\]\n\nDividing by the nonzero determinant gives Cramer's formula.\n\nThe 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."
    },
    {
      "heading": "Geometric interpretation",
      "text": "When \\(\\det(A)\\ne0\\), the columns of \\(A\\) form a basis of the coordinate vector space. Solving \\(A\\mathbf{x}=\\mathbf{b}\\) means finding the coordinates of \\(\\mathbf{b}\\) in that basis.\n\nOver the real numbers, a determinant represents oriented area in two dimensions, oriented volume in three dimensions, and the corresponding higher-dimensional quantity. Replacing \\(\\mathbf{a}_i\\) by \\(\\mathbf{b}\\) changes this oriented volume by the factor \\(x_i\\). Thus\n\n\\[x_i= \\frac{\\text{oriented volume with column }i\\text{ replaced by }\\mathbf{b}} {\\text{original oriented volume}}.\\]\n\nOrientation is essential: using absolute volumes alone would lose the sign of the coordinate."
    },
    {
      "heading": "Singular systems",
      "text": "The usual rule does not apply when \\(\\det(A)=0\\), because its denominator vanishes. Such a square system has either no solution or infinitely many solutions over the real or complex numbers.\n\nThe undivided identity\n\n\\[\\det(A_i)=x_i\\det(A)\\]\n\nstill holds whenever a solution exists. Therefore, if \\(\\det(A)=0\\) but at least one \\(\\det(A_i)\\ne0\\), the system is inconsistent.\n\nThe converse is false: if the coefficient determinant and all replacement determinants vanish, consistency is not guaranteed. For example,\n\n\\[A= \\begin{pmatrix} 1&0&0\\\\ 0&0&0\\\\ 0&0&0 \\end{pmatrix}, \\qquad \\mathbf{b}= \\begin{pmatrix} 0\\\\ 1\\\\ 0 \\end{pmatrix}.\\]\n\nEvery replacement determinant is zero, but the second equation is \\(0=1\\).\n\nThe general consistency test uses matrix rank:\n\n\\[\\operatorname{rank}(A)=\\operatorname{rank}([A\\mid\\mathbf{b}]),\\]\n\nwhere \\([A\\mid\\mathbf{b}]\\) is the augmented matrix. When this equality holds, the solution is unique precisely when the common rank equals the number of unknowns."
    },
    {
      "heading": "Computational cost and numerical behavior",
      "text": "Cramer's rule is an explicit formula, but that does not make it an efficient general-purpose algorithm.\n\nComputing each determinant by direct expansion involves factorially growing work. Using elimination to evaluate each of the \\(n+1\\) determinants independently reduces the total cost to \\(O(n^4)\\) arithmetic operations in big-O notation. By comparison, conventional Gaussian elimination or LU decomposition solves a dense square system in \\(O(n^3)\\) operations.\n\nThese 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.\n\nIn 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.\n\nThe 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, \\(A=\\varepsilon I\\), with nonzero real \\(\\varepsilon\\), has determinant \\(\\varepsilon^n\\) but condition number \\(1\\) in the Euclidean norm."
    },
    {
      "heading": "Applications and historical context",
      "text": "Cramer's rule is particularly useful when explicit dependence on coefficients matters. If the entries of \\(A\\) and \\(\\mathbf{b}\\) depend polynomially on parameters, the formula expresses each solution coordinate as a ratio of polynomials wherever \\(\\det(A)\\ne0\\). This makes it useful in symbolic algebra and in identifying parameter values at which a system ceases to have a unique solution.\n\nFor an invertible matrix with integer entries and an integer right-hand side, the rule shows that every solution coordinate is rational. If \\(\\det(A)=1\\) or \\(-1\\), every solution coordinate is an integer.\n\nCramer 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."
    }
  ],
  "links": [
    "linear-algebra",
    "system-of-linear-equations",
    "determinant",
    "matrix",
    "field-mathematics",
    "real-number",
    "complex-number",
    "linear-combination",
    "multilinear-map",
    "inverse-matrix",
    "basis-linear-algebra",
    "vector-space",
    "matrix-rank",
    "big-o-notation",
    "gaussian-elimination",
    "lu-decomposition",
    "floating-point-arithmetic",
    "numerical-stability",
    "condition-number",
    "polynomial",
    "integer"
  ],
  "sources": [],
  "license": "https://creativecommons.org/licenses/by/4.0/"
}