ExamSaathi learning library · Government exams · UPSC NDA and NA Examination (II) 2026, Paper I Mathematics: matrices and determinants, solution of linear equations by Cramer's rule and by the matrix method, n · Mathematics

Cramer's rule: solving two or three linear equations with determinants

Solve two or three linear equations by Cramer's rule: build D, D_p, D_q and D_r by putting the constants in place of one column, and divide only when D is not 0. See what D = 0 means, when a homogeneous system has non-zero solutions, and when the matrix method or elimination is less work.

Status: original pilot lesson. Teacher review is pending. It is not a complete course or official exam material.

You will learn to

Before you start

This lesson leans on two earlier ones. From "Determinants for Class 12: minors, cofactors, adjoint, inverse and linear systems": det[a, b; c, d] = ad - bc, and a 3 x 3 determinant is found by going along any one row or column and adding each entry times its cofactor, which is its minor with a sign from the pattern + - +, - + -, + - +. From "Matrices for Class 12: types, operations, transpose and symmetric matrices": matrices multiply row by column, I is the identity matrix, and a square matrix A has the inverse A^(-1) when A A^(-1) = A^(-1) A = I. Together these give the inverse-matrix method, also called the matrix method. Put the coefficients in A, the unknowns in the column U = [p; q; r] and the constants in the column B, so that the system reads A U = B. If det A is not 0, the column of unknowns equals A^(-1) times the column of constants: U = A^(-1) B. The unknowns here are p, q and r, because x is kept for multiplication; many books call them x, y and z. A matrix is written row by row with semicolons between rows, so [3, 2; 2, 5] has rows 3, 2 and 2, 5, and det[3, 2; 2, 5] is its determinant. The NDA & NA (II) 2026 notice lists, in its Paper I Mathematics syllabus, "Applications-Solution of a system of linear equations in two or three unknowns by Cramer’s rule and by Matrix Method."

The core idea: Cramer's rule with D, D_p, D_q and D_r

Cramer's rule works on a system with as many equations as unknowns. Take a1 p + b1 q = c1 and a2 p + b2 q = c2. The coefficient determinant is D = det[a1, b1; a2, b2]. Copy D, but put the constants c1, c2 where the p coefficients a1, a2 stood to get D_p = det[c1, b1; c2, b2]; put them where the q coefficients b1, b2 stood to get D_q = det[a1, c1; a2, c2]. These two are the numerator determinants. When D is not 0, the system has exactly one solution: p = D_p/D and q = D_q/D. The reason is short. Multiply the first equation by b2 and the second by b1, then subtract. The q terms cancel and (a1 b2 - a2 b1) p = c1 b2 - c2 b1, which says D x p = D_p. Removing p in the same way gives D x q = D_q, and putting the two values back shows that they do satisfy both equations. Three equations in three unknowns follow the same plan. Line up the p, q and r coefficients in columns 1, 2 and 3 of D, which is now a 3 x 3 determinant. D_p, D_q and D_r come from putting the column of constants in place of column 1, 2 or 3, leaving the other two columns alone. When D is not 0, p = D_p/D, q = D_q/D and r = D_r/D give the only solution. Whatever the value of D, any solution of such a system obeys D x p = D_p, D x q = D_q and D x r = D_r, and that fact explains the case D = 0 below.

Second idea: Cramer's rule beside the matrix method and elimination

When D is not 0, Cramer's rule and the matrix method agree. Here A^(-1) = (1/D) adj A, and (adj A) B = [D_p; D_q; D_r], because each entry is the cofactor expansion of D_p, D_q or D_r down the column that holds the constants. So U = A^(-1) B gives p = D_p/D, q = D_q/D and r = D_r/D. Which is less work? For two unknowns Cramer's rule needs only three 2 x 2 determinants, and it suits a question about one unknown, since D and one numerator determinant are enough. For three unknowns it needs four 3 x 3 determinants; elimination usually needs fewer multiplications. For one system the matrix method (D, nine cofactors and a product) is about as long as Cramer's rule, but A^(-1) can be reused for new constants with the same coefficients. When D = 0 the matrix method stops, since A has no inverse; the numerator determinants may settle the case, and elimination always does. The CBSE Mathematics (041) curriculum for 2026-27 lists, under Class XII Determinants, "Determinant of a square matrix (up to 3 x 3 matrices), minors, co-factors ..." and "Consistency, inconsistency and number of solutions of system of linear equations by examples, solving system of linear equations in two or three variables (having unique solution) using inverse of a matrix." That list names the inverse-matrix method and does not name Cramer's rule; the NDA & NA notice names both.

A further case: D = 0 and homogeneous systems

If D = 0, there is no unique solution: the system has no solution or infinitely many, and p = D_p/D must not be used. Go back to D x p = D_p. If D = 0 but a numerator determinant, say D_p, is not 0, that equation reads 0 = D_p, which no p can satisfy, so the system is inconsistent and has no solution. For two equations, each with at least one non-zero coefficient so that each is a genuine line, D = 0 with D_p = D_q = 0 means the two lines are the same, and there are infinitely many solutions. With p and q for the prices of a pen and an eraser, bills of Rs. 40 for 2 pens and 3 erasers and Rs. 90 for 4 pens and 6 erasers give D = 2 x 6 - 3 x 4 = 0 and D_p = 40 x 6 - 3 x 90 = -30, so no prices fit both bills and one bill is wrong. With Rs. 80 on the second bill, D_p = 240 - 240 = 0 and D_q = 2 x 80 - 4 x 40 = 0: that bill is the first one doubled, and infinitely many pairs (p, q) fit, so the bills cannot fix the prices. For three unknowns, D = 0 with every numerator determinant 0 does not prove infinitely many solutions, because such a system can still have none, so decide by elimination. A homogeneous system has every constant equal to 0. It always has the zero, or trivial, solution p = q = r = 0. If D is not 0, that is its only solution, since each numerator determinant has a column of zeros. If D = 0, it has infinitely many solutions, non-zero ones included.

Common mistakes

Replacing the wrong column. D_p puts the constants in the p column, D_q in the q column and D_r in the r column, and the other columns stay as they were. Replacing a row, or the column of another unknown, gives a different number: in worked example 1, putting the bill amounts in the p column and calling the result D_q would give q = 330/11 = 30, which is the notebook's price. Sign errors in the cofactor expansion. Along row 1 the signs are +, -, +. The minus belongs to the middle position, so a middle entry of -1 contributes -(-1) times its minor, that is, plus the minor. Write each sign before you multiply. Dividing by D = 0. When D = 0, D_p/D has no meaning; stop and test the numerator determinants or use elimination. Assuming that D = 0 always means no solution. D = 0 only rules out a unique solution, and worked example 3 has infinitely many. The reverse slip matters too: with three unknowns, every numerator determinant being 0 is not proof of infinitely many solutions. Forgetting a missing unknown. Write p + q = 1 as p + q + 0r = 1, and keep the unknowns in the same order in every equation with the constants on the right. Turning the fraction over. The rule is p = D_p/D, not D/D_p.

A short routine for Cramer's rule

Step 1: Write each equation as the p term, the q term (and the r term) equal to a constant, in the same order, using 0 for a missing unknown. Step 2: Find D. For a 3 x 3 determinant, expand along the row or column with the most zeros and write the signs + - +, - + -, + - + before multiplying. Step 3: If D is not 0, build D_p, D_q (and D_r) by putting the constants in place of that unknown's column, then divide: p = D_p/D, q = D_q/D, r = D_r/D. Step 4: If D = 0, do not divide. Any non-zero numerator determinant means no solution. For two genuine lines with both numerators 0, there are infinitely many solutions. For three unknowns with all numerators 0, finish by elimination. Step 5: For a homogeneous system, D not 0 means only p = q = r = 0, and D = 0 means infinitely many solutions. Step 6: Put the answer back into every original equation.

Worked examples

  1. At a stationery shop in Pune, Meera pays Rs. 130 for 3 notebooks and 2 pens, and Arjun pays Rs. 160 for 2 notebooks and 5 pens. Every notebook costs the same and every pen costs the same. Find both prices by Cramer's rule.

    1. Step 1: Let a notebook cost Rs. p and a pen cost Rs. q. The bills give 3p + 2q = 130 and 2p + 5q = 160.
    2. Step 2: D = det[3, 2; 2, 5] = 3 x 5 - 2 x 2 = 15 - 4 = 11. Since D is not 0, exactly one pair of prices fits.
    3. Step 3: Put 130 and 160 in place of the p column: D_p = det[130, 2; 160, 5] = 130 x 5 - 2 x 160 = 650 - 320 = 330.
    4. Step 4: Put 130 and 160 in place of the q column: D_q = det[3, 130; 2, 160] = 3 x 160 - 130 x 2 = 480 - 260 = 220.
    5. Step 5: p = D_p/D = 330/11 = 30 and q = D_q/D = 220/11 = 20. Check: 3 x 30 + 2 x 20 = 90 + 40 = 130 and 2 x 30 + 5 x 20 = 60 + 100 = 160.

    Answer: A notebook costs Rs. 30 and a pen costs Rs. 20 (D = 11, D_p = 330 and D_q = 220).

  2. Solve 2p + q - r = 7, p - 2q + 3r = 2 and 3p + q + 2r = 13 by Cramer's rule.

    1. Step 1: D = det[2, 1, -1; 1, -2, 3; 3, 1, 2]. Along row 1 with the signs +, -, +: D = 2 x (-2 x 2 - 3 x 1) - 1 x (1 x 2 - 3 x 3) + (-1) x (1 x 1 - (-2) x 3) = -14 + 7 - 7 = -14, which is not 0.
    2. Step 2: Constants 7, 2, 13 in column 1: D_p = det[7, 1, -1; 2, -2, 3; 13, 1, 2] = 7 x (-4 - 3) - 1 x (4 - 39) + (-1) x (2 + 26) = -49 + 35 - 28 = -42.
    3. Step 3: Constants in column 2: D_q = det[2, 7, -1; 1, 2, 3; 3, 13, 2] = 2 x (4 - 39) - 7 x (2 - 9) + (-1) x (13 - 6) = -70 + 49 - 7 = -28.
    4. Step 4: Constants in column 3: D_r = det[2, 1, 7; 1, -2, 2; 3, 1, 13] = 2 x (-26 - 2) - 1 x (13 - 6) + 7 x (1 + 6) = -56 - 7 + 49 = -14.
    5. Step 5: p = -42/(-14) = 3, q = -28/(-14) = 2 and r = -14/(-14) = 1. Check: 6 + 2 - 1 = 7, 3 - 4 + 3 = 2 and 9 + 2 + 2 = 13.

    Answer: p = 3, q = 2 and r = 1.

  3. Riya tries Cramer's rule on p + q + r = 7, p + 2q + 3r = 12 and 2p + 3q + 4r = 19. Does the system have one solution, none or infinitely many?

    1. Step 1: D = det[1, 1, 1; 1, 2, 3; 2, 3, 4] = 1 x (8 - 9) - 1 x (4 - 6) + 1 x (3 - 4) = -1 + 2 - 1 = 0. There is no unique solution, so p = D_p/D cannot be used.
    2. Step 2: D_p = det[7, 1, 1; 12, 2, 3; 19, 3, 4] = 7 x (8 - 9) - 1 x (48 - 57) + 1 x (36 - 38) = -7 + 9 - 2 = 0. Likewise D_q = det[1, 7, 1; 1, 12, 3; 2, 19, 4] = -9 + 14 - 5 = 0 and D_r = det[1, 1, 7; 1, 2, 12; 2, 3, 19] = 2 + 5 - 7 = 0.
    3. Step 3: No numerator determinant is non-zero, so the system is not shown to be inconsistent. With three unknowns, though, four zeros do not prove infinitely many solutions, so use elimination.
    4. Step 4: The third equation is the sum of the first two (1 + 1 = 2, 1 + 2 = 3, 1 + 3 = 4 and 7 + 12 = 19), so it adds nothing new. Subtracting the first equation from the second leaves q + 2r = 5.
    5. Step 5: Let r = t, where t is any number. Then q = 5 - 2t and p = 7 - q - r = 2 + t. For t = 1 this gives (3, 3, 1) and for t = 2 it gives (4, 1, 2); each fits all three equations.

    Answer: D = 0, and the system has infinitely many solutions: p = 2 + t, q = 5 - 2t and r = t for any number t, for example (3, 3, 1) and (4, 1, 2). Here D = 0 did not mean 'no solution'.

Practice checks

  1. At a school canteen, 2 samosas and 3 cups of tea cost Rs. 55, and 3 samosas and 2 cups of tea cost Rs. 70. With p for the price of a samosa and q for a cup of tea, what does Cramer's rule give for q?
  2. For p - q + r = 6, p + q = 1 and 3p + 2q - 2r = -2, the coefficient determinant is D = -5. What value of r does Cramer's rule give?
  3. For which value of k does the system 3p - 6q = 9 and -p + 2q = k have infinitely many solutions?
  4. For which value of k does the homogeneous system p + q + r = 0, p + 2q + kr = 0 and p + 3q + 5r = 0 have a solution other than p = q = r = 0?
  5. For p + 2q - r = 3, 2p + 4q - 2r = 5 and -p - 2q + r = 1, Neha finds D = D_p = D_q = D_r = 0 and writes 'infinitely many solutions'. What is correct?

Sources checked