Arithmetic, Algebra & Number Theory Equations, Systems & Polynomials Cramer's rule for a 2×2 linear system

System of 2 Linear Equations Calculator (2×2)

Two linear equations in two unknowns describe two straight lines, and solving the system means finding where they cross. Enter the six coefficients of a₁x + b₁y = c₁ and a₂x + b₂y = c₂ and this calculator applies Cramer's rule to return x and y, along with the three determinants that produce them. The main determinant also classifies the system before you look at the answer: non-zero means one intersection point, zero means the lines are either parallel with no solution or identical with infinitely many.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
a₁ — coefficient of x, equation 1Write the equation as a₁x + b₁y = c₁ first, moving every variable to the left and the constant to the right.2
b₁ — coefficient of y, equation 1Enter 0 if y does not appear in the first equation.3
c₁ — constant, equation 1The number on the right-hand side after rearranging.12
a₂ — coefficient of x, equation 2The x coefficient of the second equation, in the same arranged form.1
b₂ — coefficient of y, equation 2Include the sign: x − y = 1 has b₂ = −1.-1
c₂ — constant, equation 2The right-hand side of the second equation.1

It returns

  • x — The x coordinate of the intersection point.
  • y — The y coordinate of the intersection point.
  • Main determinant D — a₁b₂ − a₂b₁. Zero means the lines are parallel or identical.
  • Determinant Dₓ — The main determinant with the x column replaced by the constants.
  • Determinant Dᵧ

The formula

x=c1b2c2b1a1b2a2b1
y=a1c2a2c1D

In plain text: x = (c₁b₂ − c₂b₁) / D, y = (a₁c₂ − a₂c₁) / D, D = a₁b₂ − a₂b₁

  • a₁, b₁, c₁Coefficients of the first equation, arranged as a₁x + b₁y = c₁ (any)
  • a₂, b₂, c₂Coefficients of the second equation (any)
  • DMain determinant of the coefficient matrix; zero means no unique solution (any)

Cramer's rule is the closed-form solution of the 2×2 system. It is efficient at this size and impractical for large systems, where elimination is used instead.

Updated Category Equations, Systems & Polynomials Verified against published test cases Reading time 10 min

What a 2×2 system is asking

Each linear equation in two unknowns describes a straight line: every point (x, y) on that line satisfies the equation, and no other point does. Two equations therefore describe two lines, and solving them together means finding the point that satisfies both — the point where they cross.

Geometry tells you immediately that only three outcomes are possible. Two lines in a plane either cross at exactly one point, or run parallel and never meet, or lie exactly on top of one another and share every point. There is no fourth case, and no way for two straight lines to meet at two isolated points.

That geometric fact has an algebraic counterpart, which is the whole reason the determinant is worth computing. D = a₁b₂ − a₂b₁ is zero exactly when the two coefficient pairs are proportional, which is exactly when the lines have the same slope. So a non-zero D guarantees one intersection point, and a zero D means the lines are either parallel or identical — a distinction you settle by checking whether the constants are in the same proportion as the coefficients.

Systems like this appear wherever two conditions must hold at once: a break-even point where cost and revenue lines meet, a mixture of two solutions reaching a target concentration and volume, a supply curve crossing a demand curve, two forces balancing in a truss joint.

Cramer's rule, and how it relates to elimination

Cramer's rule solves the system in closed form. Build three determinants from the coefficients:

  • D = a₁b₂ − a₂b₁ — the determinant of the coefficients alone.
  • Dx = c₁b₂ − c₂b₁ — the same, with the x column replaced by the constants.
  • Dy = a₁c₂ − a₂c₁ — with the y column replaced by the constants.

Then x = Dx/D and y = Dy/D, provided D is not zero. A 2×2 determinant is just the product of the main diagonal minus the product of the other diagonal, which makes the whole method six multiplications and three subtractions.

The rule is not magic; it is elimination written out in advance. Multiply the first equation by b₂ and the second by b₁, subtract, and the y terms cancel, leaving (a₁b₂ − a₂b₁)x = c₁b₂ − c₂b₁. That is D·x = Dx. Doing the same with the a coefficients gives the y equation. Every step of Cramer's rule is a step of elimination you would have taken anyway.

Two other standard methods give the same answer. Substitution solves one equation for one variable and pushes it into the other; it is quickest when a coefficient is 1, as in x − y = 1. Elimination scales the equations so one variable cancels when you add or subtract; it is quickest when the coefficients already share a factor. Graphing is the least precise but the most instructive, because it makes the three outcomes visible.

Where Cramer's rule earns its place is diagnosis. You compute D first, and it tells you what kind of system you have before you have committed to solving it — something substitution only reveals when you reach an absurdity like 0 = 3.

Worked example: 2x + 3y = 12 and x − y = 1

Solve the pair by all three routes and confirm they agree.

By Cramer's rule.

  1. D = (2)(−1) − (1)(3) = −2 − 3 = −5. Non-zero, so exactly one solution exists.
  2. Dx = (12)(−1) − (1)(3) = −12 − 3 = −15.
  3. Dy = (2)(1) − (1)(12) = 2 − 12 = −10.
  4. x = −15 ÷ −5 = 3; y = −10 ÷ −5 = 2.

By substitution. The second equation gives x = y + 1. Substituting into the first: 2(y + 1) + 3y = 12, so 2y + 2 + 3y = 12, so 5y = 10 and y = 2. Then x = 2 + 1 = 3.

By elimination. Multiply the second equation by 3: 3x − 3y = 3. Add it to the first: (2x + 3x) + (3y − 3y) = 12 + 3, so 5x = 15 and x = 3. Substituting back gives y = 2.

Check both equations. 2(3) + 3(2) = 6 + 6 = 12 ✓, and 3 − 2 = 1 ✓. Checking one equation only is not enough — an arithmetic slip in the elimination step usually still satisfies the equation you worked from, and fails the other one.

Now break it deliberately. Change the second equation to 4x + 6y = 20. Then D = (2)(6) − (4)(3) = 12 − 12 = 0, so there is no unique solution. Is it parallel or identical? The coefficients of the second equation are exactly twice the first, but the constant 20 is not twice 12. Different intercepts, same slope: parallel, no solution. Had the constant been 24, every ratio would have matched and the two equations would describe one line with infinitely many solutions.

Reading the determinant before you read the answer

Look at D first. A non-zero D means the lines cross once and the values of x and y are the coordinates of that point. Zero means no unique answer, and the two sub-determinants tell you which kind: if Dx and Dy are both zero as well, the equations are multiples of one another and describe the same line; if either is non-zero, the lines are parallel and the system is inconsistent.

A small but non-zero D deserves suspicion. It means the lines cross at a shallow angle, so the intersection point is sensitive to the coefficients — nudge a coefficient in the third decimal place and the crossing point may move substantially. In applied work this is called ill-conditioning, and the practical response is to check how precisely you actually know your coefficients before quoting the answer to many figures.

Interpret the signs in context. A negative x is perfectly valid algebra but may be meaningless as a quantity of material or a number of units, in which case the model rather than the arithmetic is at fault. Fractional answers are equally valid: two lines with whole-number coefficients frequently cross at a point with fractional coordinates, and rounding to whole numbers puts you on neither line.

Always substitute back into both equations. The residual column in the results table is the left-hand side minus the right-hand side, and it should be zero. With decimal coefficients you may see something like 1e−15, which is floating-point rounding rather than error. Anything larger points at a mis-entered coefficient.

Determinants and what they mean, with worked systems

Each row gives a complete system, its three determinants, and the resulting classification. Compute D first and the rest follows.
SystemDDxDyOutcome
2x + 3y = 12; x − y = 1−5−15−10One solution: (3, 2)
3x + 2y = 12; x + 4y = 14102030One solution: (2, 3)
5x = 10; 2y = 6102030One solution: (2, 3)
2x + y = 5; x − 3y = 6−7−217One solution: (3, −1)
x + y = 2; 2x + 2y = 50−11Parallel: no solution
2x + y = 5; 4x + 2y = 110−12Parallel: no solution
x + y = 2; 2x + 2y = 4000Same line: infinitely many
4x − 2y = 6; −2x + y = −3000Same line: infinitely many

Rows two and three show that different systems can share all three determinants: 5x = 10 with 2y = 6 gives the same D, Dₓ and Dᵧ as 3x + 2y = 12 with x + 4y = 14, and therefore the same solution point.

Where 2×2 systems go wrong

  • Not rearranging first. Cramer's rule needs the form a x + b y = c. An equation given as y = 2x − 5 must become −2x + y = −5 before its coefficients mean anything here.
  • Dropping a sign. In x − y = 1 the coefficient b₂ is −1, not 1. A sign error in one coefficient flips the determinant and moves the answer somewhere plausible but wrong.
  • Forgetting a zero coefficient. If an equation is 5x = 10, then b is 0, not blank. Leaving it out of the determinant is the same as omitting a term.
  • Concluding 'no solution' from D = 0 alone. D = 0 covers both the parallel case and the identical-line case, and those are opposite conclusions. Check Dₓ and Dᵧ before deciding.
  • Checking only one equation. A solution derived from equation 1 will usually satisfy equation 1 even when it is wrong. The second check is the one that catches errors.
  • Rounding an intermediate determinant. Determinants of similar-sized products lose precision through cancellation: 12.001 − 12.000 keeps only one significant figure. Carry full precision to the division.

Beyond two equations

A single linear equation in one unknown needs none of this machinery — the linear equation solver isolates the variable directly, and it is the tool to reach for once substitution has reduced your system to one equation.

Cramer's rule extends to 3×3 and beyond, but the cost grows factorially and the arithmetic becomes unmanageable by hand, so larger systems are solved by Gaussian elimination instead. The determinant keeps the same meaning at every size: zero means the system has no unique solution.

If the unknowns appear squared or multiplied together, the system is no longer linear and lines become curves, which can intersect at two points, none, or a tangent. A single quadratic in one unknown is handled by the quadratic equation calculator, and the discriminant there plays exactly the role the determinant plays here — a single number computed first that tells you how many solutions to expect.

Many word problems reduce to a 2×2 system only after a ratio has been set up correctly. Mixture, scaling and rate problems often start as a proportion, and blending problems where both a total and a concentration must be matched are exactly this calculator's case. When the equations arrive with fractional coefficients, clearing the denominators first with the least common multiple of the denominators keeps the determinants in whole numbers and the arithmetic exact.

Frequently asked questions

How do I solve two equations with two unknowns?

Rearrange both into the form ax + by = c, then eliminate one variable. Cramer's rule does this in closed form: compute D = a₁b₂ − a₂b₁, then x = (c₁b₂ − c₂b₁)/D and y = (a₁c₂ − a₂c₁)/D. Substitution and elimination give the same answer and are often quicker by hand when a coefficient happens to be 1.

What does it mean when the determinant is zero?

It means the two lines have the same slope, so there is no single intersection point. Which of the two zero-determinant cases you have depends on Dₓ and Dᵧ: if both are also zero, the equations describe the same line and every point on it is a solution; if either is non-zero, the lines are parallel and there is no solution at all.

Is Cramer's rule better than substitution or elimination?

For a 2×2 system they are equally accurate, and Cramer's rule is the most mechanical — six multiplications and three subtractions, no choices to make. Its real advantage is that computing D first classifies the system before you solve it. For systems larger than 3×3, Cramer's rule becomes far slower than elimination and is not used in practice.

What if one of my equations has no y term?

Enter its y coefficient as 0. An equation like 5x = 10 is a valid line — a vertical one at x = 2 — and Cramer's rule handles it without any special treatment. The only forbidden case is an equation whose x and y coefficients are both zero, which is not a line at all.

Why does my answer come out as a fraction?

Because x and y are each a ratio of two determinants, and there is no reason for that ratio to be whole. Two lines with whole-number coefficients commonly cross at fractional coordinates. Round only at the very end and only if the context requires it, since a rounded point lies on neither line.

How do I set up a word problem as a 2×2 system?

Name the two unknowns, then write one equation for each independent piece of information. Mixture problems usually give a total quantity and a total value or concentration; distance problems give a total distance and a total time. If both statements say the same thing in different words, you will end up with a zero determinant and no unique answer, which is the algebra telling you the problem is underdetermined.

Can a 2×2 system have exactly two solutions?

No. Two straight lines in a plane meet either once, never, or everywhere. Two isolated solutions require at least one curved relationship — a quadratic, a circle, a hyperbola — and then the system is no longer linear and this method does not apply.

What does a very small determinant tell me?

That the lines cross at a shallow angle, so the intersection is highly sensitive to the coefficients. A change in the fourth decimal place of one coefficient can move the answer noticeably. If your coefficients came from measurements, quote the answer to far fewer figures than the calculator displays, or reformulate the problem.

References

  • Linear Algebra and Its Applications, 6th ed. — Pearson (David C. Lay)
  • Basic Mathematics — Springer (Serge Lang)
  • Matrix Computations, 4th ed. — Johns Hopkins University Press (Golub and Van Loan)