Siksha Sarovar

Siksha Sarovar (sikshasarovar.com) is a free educational web application that helps students in India learn programming and prepare for academic and competitive exams. The platform offers structured coding courses (C, C++, Python, Java, HTML, CSS, PHP, Power BI, AI, Machine Learning, Data Science), complete university curriculum notes for BCA/MCA students with previous year question papers, Class 10 and Class 12 CBSE/HBSE school notes, and dedicated preparation material for SSC, UPSC, Banking, Railway and other government exams. Browsing the site is completely free and requires no account. Users may optionally sign in with Google solely to save their learning progress, quiz scores and personal preferences across devices.

Privacy Policy | Terms of Service | Contact Siksha Sarovar | About Siksha Sarovar

v4.0.9 · PWA
Siksha Sarovar logo
Siksha Sarovar
Your Learning Universe

Siksha Sarovar is a free e-learning platform for coding courses, BCA university notes and competitive exam preparation. Optional Google sign-in saves your learning progress across devices.

Initializing knowledge base…
Compiling modules 0%

Unit 5: Matrices, Determinants & Linear Systems

Lesson 16 of 17 in the free Mathematical Foundation of CS notes on Siksha Sarovar, written by Rohit Jangra.

15.1 Matrices and Their Types

An m × n matrix is a rectangular array of numbers with m rows and n columns; A[i][j] denotes the entry in row i, column j.

TypeDefinition
Row / column matrix1 × n / m × 1
Squarem = n
Diagonalsquare, non-diagonal entries 0
Scalar / Identity Idiagonal with equal entries / all 1s
Zero matrix Oall entries 0
Transpose A^Trows and columns swapped: A^T[i][j] = A[j][i]
Symmetric / Skew-symmetricA^T = A / A^T = −A

15.2 Matrix Operations

  • Addition/subtraction: entrywise; only for identical dimensions.
  • Scalar multiplication: multiply every entry.
  • Multiplication: A (m × n) times B (n × p) gives C (m × p) with C[i][j] = Σ (k = 1..n) A[i][k]·B[k][j] — row i of A dotted with column j of B. Inner dimensions must match.

Worked check that AB ≠ BA. Let A = [[1, 2], [3, 4]] and B = [[0, 1], [1, 0]].

  1. AB = [[1·0 + 2·1, 1·1 + 2·0], [3·0 + 4·1, 3·1 + 4·0]] = [[2, 1], [4, 3]] (B swaps A's columns).
  2. BA = [[0·1 + 1·3, 0·2 + 1·4], [1·1 + 0·3, 1·2 + 0·4]] = [[3, 4], [1, 2]] (B swaps A's rows).

AB ≠ BA — matrix multiplication is associative and distributive but not commutative. Useful identities: (AB)^T = B^T·A^T; A·I = I·A = A.

15.3 Determinants

The determinant maps a square matrix to a scalar measuring invertibility (and volume scaling).

  • 2 × 2: det [[a, b], [c, d]] = ad − bc.
  • 3 × 3 (cofactor expansion along row 1): det A = a11·M11 − a12·M12 + a13·M13, where Mij is the determinant of the 2 × 2 minor left after deleting row i and column j; signs follow the checkerboard (−1)^(i+j).

Worked Example 1. A = [[2, 1, 3], [0, 4, 1], [5, 2, 0]].

  1. det A = 2·det[[4, 1], [2, 0]] − 1·det[[0, 1], [5, 0]] + 3·det[[0, 4], [5, 2]]
  2. = 2(4·0 − 1·2) − 1(0·0 − 1·5) + 3(0·2 − 4·5)
  3. = 2(−2) − (−5) + 3(−20) = −4 + 5 − 60 = −59.

Properties: det(AB) = det A · det B; det A^T = det A; swapping two rows flips the sign; a row of zeros or two identical rows forces det = 0; det(kA) = k^n det A for an n × n matrix.

15.4 Inverse of a Matrix

A square matrix A is invertible (non-singular) iff det A ≠ 0, and then A⁻¹ = adj(A)/det(A), where adj(A) is the transpose of the cofactor matrix. For 2 × 2 this collapses to a formula worth memorizing:

[[a, b], [c, d]]⁻¹ = (1/(ad − bc)) · [[d, −b], [−c, a]] — swap the diagonal, negate the off-diagonal.

Worked Example 2. A = [[4, 7], [2, 6]]: det A = 24 − 14 = 10 ≠ 0, so A⁻¹ = (1/10)·[[6, −7], [−2, 4]] = [[0.6, −0.7], [−0.2, 0.4]]. Verify: A·A⁻¹ = (1/10)·[[4·6 + 7·(−2), 4·(−7) + 7·4], [2·6 + 6·(−2), 2·(−7) + 6·4]] = (1/10)·[[10, 0], [0, 10]] = I ✔.

15.5 Solving Linear Systems — Cramer's Rule

The system a1x + b1y = c1, a2x + b2y = c2 is A·X = B with coefficient matrix A. If D = det A ≠ 0, Cramer's rule gives x = Dx/D and y = Dy/D, where Dx (resp. Dy) replaces the x-column (resp. y-column) of A with B.

Worked: x + 2y = 5 and 3x − y = 1.

  1. D = det[[1, 2], [3, −1]] = −1 − 6 = −7.
  2. Dx = det[[5, 2], [1, −1]] = −5 − 2 = −7 → x = (−7)/(−7) = 1.
  3. Dy = det[[1, 5], [3, 1]] = 1 − 15 = −14 → y = (−14)/(−7) = 2.
  4. Check: 1 + 2·2 = 5 ✔ and 3·1 − 2 = 1 ✔. Equivalently X = A⁻¹B. If D = 0 the system has no solution or infinitely many — never a unique one; and for large n, Gaussian elimination (O(n^3)) replaces Cramer's rule (O(n·n!)) in practice.

15.6 Adjacency Matrices — Matrices Meet Graphs

A graph with vertices v1..vn is stored as the adjacency matrix A with A[i][j] = 1 iff vi–vj is an edge; undirected graphs give symmetric A. Theorem: (A^k)[i][j] counts walks of length k from vi to vj.

Check on the triangle C3: A = [[0,1,1],[1,0,1],[1,1,0]]; then A^2 = [[2,1,1],[1,2,1],[1,1,2]]. Diagonal entries 2 = deg(vi) (each length-2 walk out-and-back uses one incident edge); off-diagonal 1 = the single length-2 walk between distinct vertices via the third one. Powers of A drive reachability, transitive closure (Warshall), Markov chains, and PageRank; graphics pipelines multiply 4 × 4 transformation matrices per vertex.

15.7 Common Mistakes

  • Assuming AB = BA, or cancelling matrices (AB = AC does not imply B = C unless A is invertible).
  • Forgetting cofactor signs (−1)^(i+j) in 3 × 3 expansions.
  • Dividing by det A = 0 — always test the determinant before inverting.

🎯 Exam Focus

  1. If A = [[1, 2], [3, 4]] and B = [[2, 0], [1, 3]], compute AB, BA, and (AB)^T, and verify (AB)^T = B^T·A^T.
  2. Evaluate det[[1, 2, 3], [4, 5, 6], [7, 8, 9]] and explain the significance of the result.
  3. Find the inverse of [[2, 1, 1], [1, 2, 1], [1, 1, 2]] by the adjoint method.
  4. Solve by Cramer's rule: 2x + y − z = 3, x − y + 2z = 1, 3x + 2y + z = 4.
  5. For the path graph P3 (v1–v2–v3), write A and compute A^2 and A^3. How many length-3 walks go from v1 to v2?
  6. Prove that a square matrix with two identical rows has determinant zero.