Section 1 · 9 min read

Linear algebra

Matrix types, determinants, rank, solving linear systems, eigenvalues and eigenvectors with their shortcut properties, Cayley-Hamilton, and LU decomposition.

On this page
  1. Matrix basics
  2. Systems of linear equations
  3. Eigenvalues and eigenvectors
  4. LU decomposition
  5. Worked examples
  6. Common traps
  7. Quick revision

Linear algebra questions in GATE CS are mostly computational: an eigenvalue or determinant to find, a rank to determine, a system to classify as having zero, one or infinitely many solutions. Most can be solved in under two minutes if you use the shortcut properties instead of expanding characteristic polynomials by brute force.

Matrix basics

Special matrices

Type Definition Useful fact
Symmetric AT=AA^T = A real eigenvalues, orthogonal eigenvectors
Skew-symmetric AT=−AA^T = -A diagonal is zero; odd order implies det⁡A=0\det A = 0; eigenvalues are 0 or purely imaginary
Orthogonal ATA=IA^T A = I det⁡A=±1\det A = \pm 1, eigenvalues have $
Idempotent A2=AA^2 = A eigenvalues are 0 or 1; rank equals trace
Nilpotent Ak=0A^k = 0 for some kk all eigenvalues are 0
Involutory A2=IA^2 = I eigenvalues are ±1\pm 1
Triangular zero above or below the diagonal eigenvalues and determinant come from the diagonal

Every square matrix is the sum of a symmetric and a skew-symmetric matrix: A=A+AT2+A−AT2A = \frac{A + A^T}{2} + \frac{A - A^T}{2}.

Determinants

Properties for n×nn \times n matrices:

  • det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B, det⁡(AT)=det⁡A\det(A^T) = \det A, det⁡(A−1)=1/det⁡A\det(A^{-1}) = 1/\det A.
  • det⁡(kA)=kndet⁡A\det(kA) = k^n \det A. Watch the exponent.
  • Swapping two rows changes the sign. Adding a multiple of one row to another changes nothing. Multiplying one row by kk multiplies the determinant by kk.
  • Two equal or proportional rows give det⁡=0\det = 0.
  • det⁡(adj⁡A)=(det⁡A)n−1\det(\operatorname{adj} A) = (\det A)^{n-1}, and Aadj⁡(A)=(det⁡A)IA \operatorname{adj}(A) = (\det A) I.

Rank

The rank of AA is the number of linearly independent rows (equal to the number of independent columns), which is the number of nonzero rows in its row echelon form.

  • rank⁡(A)≤min⁡(m,n)\operatorname{rank}(A) \le \min(m, n) for an m×nm \times n matrix.
  • rank⁡(AB)≤min⁡(rank⁡A,rank⁡B)\operatorname{rank}(AB) \le \min(\operatorname{rank} A, \operatorname{rank} B).
  • Rank-nullity: rank⁡(A)+dim⁡null⁡(A)=n\operatorname{rank}(A) + \dim \operatorname{null}(A) = n (number of columns).
  • A square AA is invertible iff rank⁡A=n\operatorname{rank} A = n iff det⁡A≠0\det A \ne 0 iff 0 is not an eigenvalue.
  • A nonzero matrix of the form uvTuv^T has rank 1.

Systems of linear equations

For Ax=bAx = b with nn unknowns, compare r=rank⁡(A)r = \operatorname{rank}(A) and r′=rank⁡([A∣b])r' = \operatorname{rank}([A \mid b]):

Condition Solutions
r<r′r < r' none (inconsistent)
r=r′=nr = r' = n exactly one
r=r′<nr = r' < n infinitely many, with n−rn - r free variables

The homogeneous system Ax=0Ax = 0 always has x=0x = 0. It has a nonzero solution iff rank⁡A<n\operatorname{rank} A < n; for square AA, iff det⁡A=0\det A = 0. The solution set of Ax=0Ax = 0 is a subspace of dimension n−rn - r.

For questions with parameters, row reduce once with the parameters kept symbolic, then read off which values make a pivot vanish.

Eigenvalues and eigenvectors

λ\lambda is an eigenvalue of AA with eigenvector v≠0v \ne 0 if Av=λvAv = \lambda v. The eigenvalues are the roots of the characteristic polynomial det⁡(A−λI)=0\det(A - \lambda I) = 0.

Shortcut properties

For an n×nn \times n matrix with eigenvalues λ1,…,λn\lambda_1, \dots, \lambda_n (counted with multiplicity):

  • ∑λi=tr⁡(A)\sum \lambda_i = \operatorname{tr}(A) and ∏λi=det⁡A\prod \lambda_i = \det A.
  • For 2×22 \times 2: λ2−(tr⁡A)λ+det⁡A=0\lambda^2 - (\operatorname{tr} A)\lambda + \det A = 0.
  • Eigenvalues of a triangular or diagonal matrix are its diagonal entries.
  • ATA^T has the same eigenvalues as AA (eigenvectors may differ).
  • If Av=λvAv = \lambda v then for any polynomial pp, p(A)v=p(λ)vp(A)v = p(\lambda)v. So AkA^k, A+cIA + cI, kAkA have eigenvalues λk\lambda^k, λ+c\lambda + c, kλk\lambda with the same eigenvectors.
  • A−1A^{-1} has eigenvalues 1/λi1/\lambda_i, and adj⁡(A)\operatorname{adj}(A) has eigenvalues det⁡A/λi\det A / \lambda_i (for invertible AA).
  • ABAB and BABA have the same eigenvalues.
  • If every row sums to ss, then ss is an eigenvalue with eigenvector (1,1,…,1)T(1, 1, \dots, 1)^T.
  • A rank 1 matrix n×nn \times n has eigenvalue 0 with multiplicity at least n−1n - 1; the remaining eigenvalue equals the trace.

Multiplicity and diagonalization

The algebraic multiplicity of λ\lambda is its multiplicity as a root. The geometric multiplicity is dim⁡null⁡(A−λI)=n−rank⁡(A−λI)\dim \operatorname{null}(A - \lambda I) = n - \operatorname{rank}(A - \lambda I), the number of independent eigenvectors for λ\lambda. Always 1≤geometric≤algebraic.1 \le \text{geometric} \le \text{algebraic}.

AA is diagonalizable (A=PDP−1A = PDP^{-1}) iff for every eigenvalue the two multiplicities match, iff AA has nn independent eigenvectors. Sufficient conditions: nn distinct eigenvalues, or AA real symmetric. Eigenvectors for distinct eigenvalues are always linearly independent.

When A=PDP−1A = PDP^{-1}, Ak=PDkP−1A^k = PD^kP^{-1}, which is how large powers are computed.

Cayley-Hamilton theorem

Every square matrix satisfies its own characteristic equation. For 2×22 \times 2: A2−(tr⁡A)A+(det⁡A)I=0.A^2 - (\operatorname{tr} A)A + (\det A)I = 0. Uses: express A−1A^{-1} as a polynomial in AA, or reduce a high power AkA^k to a combination of II and AA.

LU decomposition

A=LUA = LU with LL lower triangular and UU upper triangular. In Doolittle form LL has 1s on its diagonal; in Crout form UU does.

How to get Doolittle factors by elimination: run Gaussian elimination without row swaps. UU is the final upper triangular matrix. The entry lijl_{ij} (i>ji > j) is the multiplier used to clear position (i,j)(i, j), that is, Ri←Ri−lijRjR_i \leftarrow R_i - l_{ij} R_j.

Facts:

  • det⁡A=det⁡U\det A = \det U in Doolittle form (product of the pivots).
  • For an invertible matrix, the factorization without row swaps exists iff every leading principal minor is nonzero (so no pivot becomes zero). Otherwise use PA=LUPA = LU with a permutation matrix PP. Example: [0110]\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix} has no LU factorization without a row swap.
  • Solving Ax=bAx = b: first Ly=bLy = b by forward substitution, then Ux=yUx = y by back substitution, each O(n2)O(n^2). The factorization costs O(n3)O(n^3) once and is reused for many right-hand sides.

Worked examples

Worked example 1: Eigenvalues by trace and determinant

A=[221131122]A = \begin{bmatrix} 2 & 2 & 1 \\ 1 & 3 & 1 \\ 1 & 2 & 2 \end{bmatrix} has one eigenvalue equal to 5. Find the others.

  1. Each row sums to 5, so 5 is an eigenvalue with eigenvector (1,1,1)T(1,1,1)^T.
  2. tr⁡A=7\operatorname{tr} A = 7, so the other two sum to 2.
  3. det⁡A=2(6−2)−2(2−1)+1(2−3)=8−2−1=5\det A = 2(6 - 2) - 2(2 - 1) + 1(2 - 3) = 8 - 2 - 1 = 5, so the other two multiply to 1.
  4. λ2−2λ+1=0\lambda^2 - 2\lambda + 1 = 0 gives λ=1,1\lambda = 1, 1.

Eigenvalues: 5,1,15, 1, 1. Since A−IA - I has rank 1, the eigenvalue 1 has 2 independent eigenvectors and AA is diagonalizable.

Worked example 2: Classifying a system

For which kk does x+2y=3x + 2y = 3, 2x+ky=62x + ky = 6 have infinitely many solutions? No solution?

  1. det⁡[122k]=k−4\det \begin{bmatrix} 1 & 2 \\ 2 & k \end{bmatrix} = k - 4. For k≠4k \ne 4, unique solution.
  2. For k=4k = 4 the second equation is 2x+4y=62x + 4y = 6, exactly twice the first. Rank 1 for both AA and [A∣b][A \mid b]: infinitely many solutions.
  3. There is no kk giving no solution, because bb was chosen proportional. If the right side were 7 instead of 6, k=4k = 4 would give no solution.

Worked example 3: Power via Cayley-Hamilton

A=[1102]A = \begin{bmatrix} 1 & 1 \\ 0 & 2 \end{bmatrix}. Express A4A^4 in terms of AA and II.

  1. tr⁡A=3\operatorname{tr} A = 3, det⁡A=2\det A = 2, so A2=3A−2IA^2 = 3A - 2I.
  2. A3=3A2−2A=3(3A−2I)−2A=7A−6IA^3 = 3A^2 - 2A = 3(3A - 2I) - 2A = 7A - 6I.
  3. A4=7A2−6A=7(3A−2I)−6A=15A−14IA^4 = 7A^2 - 6A = 7(3A - 2I) - 6A = 15A - 14I.

Check through eigenvalues 1 and 2: 15(1)−14=1=1415(1) - 14 = 1 = 1^4 and 15(2)−14=16=2415(2) - 14 = 16 = 2^4.

Worked example 4: Doolittle factorization

Factor A=[3165]A = \begin{bmatrix} 3 & 1 \\ 6 & 5 \end{bmatrix}.

  1. Multiplier l21=6/3=2l_{21} = 6 / 3 = 2.
  2. R2−2R1=(0,3)R_2 - 2R_1 = (0, 3).
  3. L=[1021]L = \begin{bmatrix} 1 & 0 \\ 2 & 1 \end{bmatrix}, U=[3103]U = \begin{bmatrix} 3 & 1 \\ 0 & 3 \end{bmatrix}.

Check: LU=[3162+3]=ALU = \begin{bmatrix} 3 & 1 \\ 6 & 2 + 3 \end{bmatrix} = A, and det⁡A=15−6=9=3⋅3\det A = 15 - 6 = 9 = 3 \cdot 3.

Worked example 5: Rank-nullity

A 4×64 \times 6 matrix has rank 3. What is the dimension of the solution space of Ax=0Ax = 0?

Nullity =n−rank⁡=6−3=3= n - \operatorname{rank} = 6 - 3 = 3. Note nn is the number of columns (unknowns), not rows.

Common traps

  • det⁡(kA)=kndet⁡A\det(kA) = k^n \det A, not kdet⁡Ak \det A.
  • Sum of eigenvalues is the trace, product is the determinant. Swapping these is a frequent error.
  • Eigenvalues of A+BA + B are not sums of eigenvalues of AA and BB in general.
  • A repeated eigenvalue does not automatically mean "not diagonalizable". Check the rank of A−λIA - \lambda I.
  • Row operations change eigenvalues. Do not row reduce before finding eigenvalues.
  • In rank-nullity, use the number of columns.
  • Forgetting that a homogeneous system is never inconsistent.
  • In LU, the multiplier goes into LL with a plus sign: if you did Ri−3RjR_i - 3R_j, then lij=3l_{ij} = 3.

Quick revision

  • det⁡(AB)=det⁡Adet⁡B\det(AB) = \det A \det B; det⁡(kA)=kndet⁡A\det(kA) = k^n \det A; det⁡(adj⁡A)=(det⁡A)n−1\det(\operatorname{adj} A) = (\det A)^{n-1}.
  • Rank + nullity = number of columns.
  • r<r′r < r': no solution. r=r′=nr = r' = n: unique. r=r′<nr = r' < n: infinitely many.
  • ∑λ=tr⁡\sum \lambda = \operatorname{tr}, ∏λ=det⁡\prod \lambda = \det.
  • Triangular: eigenvalues on the diagonal. Equal row sums ss: ss is an eigenvalue.
  • p(A)p(A) has eigenvalues p(λ)p(\lambda); A−1A^{-1} has 1/λ1/\lambda.
  • Symmetric: real eigenvalues, diagonalizable. Distinct eigenvalues: diagonalizable.
  • Geometric multiplicity =n−rank⁡(A−λI)= n - \operatorname{rank}(A - \lambda I).
  • Cayley-Hamilton (2×22 \times 2): A2−(tr⁡A)A+(det⁡A)I=0A^2 - (\operatorname{tr} A)A + (\det A)I = 0.
  • Doolittle LU: LL holds the elimination multipliers, UU is the echelon form, det⁡A=∏uii\det A = \prod u_{ii}.

Further reading

Test this section