Skip to content

Systems of Linear Equations | Mathematics

A system of mm linear equations in nn unknowns can be written as Ax=bA\mathbf{x} = \mathbf{b}Where AMm×n(R)A \in \mathcal{M}_{m \times n}(\mathbb{R}), xRn\mathbf{x} \in \mathbb{R}^n And bRm\mathbf{b} \in \mathbb{R}^m.

Gaussian elimination transforms the augmented matrix [Ab][A \mid \mathbf{b}] into row echelon Form (REF) using elementary row operations:

  1. Swap two rows (RiRjR_i \leftrightarrow R_j).
  2. Multiply a row by a non-zero scalar (RiαRiR_i \to \alpha R_i).
  3. Add a multiple of one row to another (RiRi+αRjR_i \to R_i + \alpha R_j).

A matrix is in REF if:

  • All zero rows are at the bottom.
  • The leading entry (pivot) of each non-zero row is strictly to the right of the pivot above.
  • All entries below a pivot are zero.

Reduced row echelon form (RREF) additionally requires:

  • Each pivot is 1.
  • Each pivot is the only non-zero entry in its column.

Theorem 4.1. Every matrix has a unique RREF. Two matrices are row-equivalent if and only if they Have the same RREF.

Theorem 4.2 (Rouché—Capelli). The system Ax=bA\mathbf{x} = \mathbf{b} is consistent (has at least one Solution) if and only if

rank(A)=rank([Ab])\mathrm{rank}(A) = \mathrm{rank}([A \mid \mathbf{b}])

If consistent, the solution set has dim(null(A))\dim(\mathrm{null}(A)) free parameters, where dim(null(A))=nrank(A)\dim(\mathrm{null}(A)) = n - \mathrm{rank}(A).

Proof. Let the RREF of [Ab][A \mid \mathbf{b}] have r=rank(A)r = \mathrm{rank}(A) pivots in the coefficient Columns. The system is inconsistent if and only if the last non-zero row is [001][0 \cdots 0 \mid 1] Which occurs precisely when the augmented column contains a pivot, i.e., when rank([Ab])>r\mathrm{rank}([A \mid \mathbf{b}]) \gt r.

If consistent, the rr pivot variables are determined by the nrn - r free variables, yielding nrank(A)n - \mathrm{rank}(A) degrees of freedom. \blacksquare

An LU decomposition of AMn×n(R)A \in \mathcal{M}_{n \times n}(\mathbb{R}) writes A=LUA = LU where LL is Lower triangular with 1s on the diagonal, and UU is upper triangular.

Theorem 4.3. If Gaussian elimination can be performed on AA without row exchanges, then AA Admits an LU decomposition.

Algorithm. Store the multipliers mijm_{ij} (used to eliminate entry aija_{ij}) in the lower Triangular portion. The resulting upper triangular matrix is UU And the multipliers form LL.

Worked Example. Find the LU decomposition of

A=(211433879)A = \begin{pmatrix} 2 & 1 & 1 \\ 4 & 3 & 3 \\ 8 & 7 & 9 \end{pmatrix}

Solution

Step 1: Eliminate below a11a_{11}. m21=4/2=2m_{21} = 4/2 = 2, m31=8/2=4m_{31} = 8/2 = 4.

(211011035)\begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 3 & 5 \end{pmatrix}

Step 2: Eliminate below a22a_{22}. m32=3/1=3m_{32} = 3/1 = 3.

U=(211011002)U = \begin{pmatrix} 2 & 1 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 2 \end{pmatrix}

L=(100210431)L = \begin{pmatrix} 1 & 0 & 0 \\ 2 & 1 & 0 \\ 4 & 3 & 1 \end{pmatrix}

Verify: LU=(211433879)=ALU = \begin{pmatrix} 2 & 1 & 1 \\ 4 & 3 & 3 \\ 8 & 7 & 9 \end{pmatrix} = A. \blacksquare

To solve Ax=bA\mathbf{x} = \mathbf{b}First solve Ly=bL\mathbf{y} = \mathbf{b} (forward substitution), Then Ux=yU\mathbf{x} = \mathbf{y} (back substitution).

4.4 Gaussian Elimination with Partial Pivoting

Section titled “4.4 Gaussian Elimination with Partial Pivoting”

When a pivot is zero (or very small), we swap rows to bring the largest available entry in the Current column into the pivot position. This is partial pivoting, and it improves numerical Stability.

Problem. Solve the system using Gaussian elimination with partial pivoting:

x1+2x2+x3=53x1+x2x3=22x1+3x2+4x3=11\begin{aligned} x_1 + 2x_2 + x_3 &= 5 \\ 3x_1 + x_2 - x_3 &= 2 \\ 2x_1 + 3x_2 + 4x_3 &= 11 \end{aligned}

Solution

Augmented matrix:

[Ab]=(1215311223411)[A \mid \mathbf{b}] = \begin{pmatrix} 1 & 2 & 1 & 5 \\ 3 & 1 & -1 & 2 \\ 2 & 3 & 4 & 11 \end{pmatrix}

Step 1. Column 1: largest entry is 3 in row 2. Swap R1R2R_1 \leftrightarrow R_2:

(3112121523411)\begin{pmatrix} 3 & 1 & -1 & 2 \\ 1 & 2 & 1 & 5 \\ 2 & 3 & 4 & 11 \end{pmatrix}

R2R213R1R_2 \to R_2 - \frac{1}{3}R_1, R3R323R1R_3 \to R_3 - \frac{2}{3}R_1:

(311205/34/313/307/314/329/3)\begin{pmatrix} 3 & 1 & -1 & 2 \\ 0 & 5/3 & 4/3 & 13/3 \\ 0 & 7/3 & 14/3 & 29/3 \end{pmatrix}

Step 2. Column 2: largest entry below pivot is 7/37/3 in row 3. Swap R2R3R_2 \leftrightarrow R_3:

(311207/314/329/305/34/313/3)\begin{pmatrix} 3 & 1 & -1 & 2 \\ 0 & 7/3 & 14/3 & 29/3 \\ 0 & 5/3 & 4/3 & 13/3 \end{pmatrix}

R3R357R2R_3 \to R_3 - \frac{5}{7}R_2:

(311207/314/329/3002/76/7)\begin{pmatrix} 3 & 1 & -1 & 2 \\ 0 & 7/3 & 14/3 & 29/3 \\ 0 & 0 & -2/7 & -6/7 \end{pmatrix}

Back substitution. From row 3: 27x3=67-\frac{2}{7}x_3 = -\frac{6}{7} So x3=3x_3 = 3.

From row 2: 73x2+143(3)=293\frac{7}{3}x_2 + \frac{14}{3}(3) = \frac{29}{3} So 73x2=29314=133\frac{7}{3}x_2 = \frac{29}{3} - 14 = -\frac{13}{3} Giving x2=137x_2 = -\frac{13}{7}.

From row 1: 3x1+(137)3=23x_1 + (-\frac{13}{7}) - 3 = 2 So 3x1=2+3+137=4873x_1 = 2 + 3 + \frac{13}{7} = \frac{48}{7} Giving x1=167x_1 = \frac{16}{7}.

Solution: x1=167x_1 = \frac{16}{7}, x2=137x_2 = -\frac{13}{7}, x3=3x_3 = 3. \blacksquare

When Ax=bA\mathbf{x} = \mathbf{b} is overdetermined (more equations than unknowns) and inconsistent, We seek x\mathbf{x} that minimises Axb2\lVert A\mathbf{x} - \mathbf{b} \rVert^2.

Theorem 4.4 (Normal Equations). The least squares solution x^\hat{\mathbf{x}} satisfies

ATAx^=ATbA^T A \hat{\mathbf{x}} = A^T \mathbf{b}

If AA has full column rank, then ATAA^T A is invertible and x^=(ATA)1ATb\hat{\mathbf{x}} = (A^T A)^{-1} A^T \mathbf{b}.

Proof. The error vector e=Axb\mathbf{e} = A\mathbf{x} - \mathbf{b} is minimised when ecol(A)\mathbf{e} \perp \mathrm{col}(A) I.e., when ATe=0A^T \mathbf{e} = \mathbf{0}. This gives AT(Axb)=0A^T(A\mathbf{x} - \mathbf{b}) = \mathbf{0} Or ATAx=ATbA^T A \mathbf{x} = A^T \mathbf{b}. If AA has full column rank, then ker(A)={0}\ker(A) = \{\mathbf{0}\} So ker(ATA)=ker(A)={0}\ker(A^T A) = \ker(A) = \{\mathbf{0}\}Meaning ATAA^T A is invertible. \blacksquare

Problem. Find the least squares line y=ax+by = ax + b fitting the data points (1,1)(1, 1), (2,1)(2, 1), (3,3)(3, 3).

Solution

The system is (112131)(ab)=(113)\begin{pmatrix} 1 & 1 \\ 2 & 1 \\ 3 & 1 \end{pmatrix}\begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} 1 \\ 1 \\ 3 \end{pmatrix} I.e., Ax=bA\mathbf{x} = \mathbf{b} with A=(112131)A = \begin{pmatrix} 1 & 1 \\ 2 & 1 \\ 3 & 1 \end{pmatrix} x=(a,b)T\mathbf{x} = (a, b)^T, b=(1,1,3)T\mathbf{b} = (1, 1, 3)^T.

Compute ATA=(123111)(112131)=(14663)A^T A = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 1 & 1 \end{pmatrix}\begin{pmatrix} 1 & 1 \\ 2 & 1 \\ 3 & 1 \end{pmatrix} = \begin{pmatrix} 14 & 6 \\ 6 & 3 \end{pmatrix}.

ATb=(123111)(113)=(125)A^T \mathbf{b} = \begin{pmatrix} 1 & 2 & 3 \\ 1 & 1 & 1 \end{pmatrix}\begin{pmatrix} 1 \\ 1 \\ 3 \end{pmatrix} = \begin{pmatrix} 12 \\ 5 \end{pmatrix}.

Solve (14663)(ab)=(125)\begin{pmatrix} 14 & 6 \\ 6 & 3 \end{pmatrix}\begin{pmatrix} a \\ b \end{pmatrix} = \begin{pmatrix} 12 \\ 5 \end{pmatrix}:

det(ATA)=4236=6\det(A^T A) = 42 - 36 = 6.

(ATA)1=16(36614)(A^T A)^{-1} = \frac{1}{6}\begin{pmatrix} 3 & -6 \\ -6 & 14 \end{pmatrix}.

x^=16(36614)(125)=16(363072+70)=16(62)=(11/3)\hat{\mathbf{x}} = \frac{1}{6}\begin{pmatrix} 3 & -6 \\ -6 & 14 \end{pmatrix}\begin{pmatrix} 12 \\ 5 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} 36 - 30 \\ -72 + 70 \end{pmatrix} = \frac{1}{6}\begin{pmatrix} 6 \\ -2 \end{pmatrix} = \begin{pmatrix} 1 \\ -1/3 \end{pmatrix}.

The least squares line is y=x1/3y = x - 1/3. \blacksquare

4.6 Worked Example: System with Infinitely Many Solutions

Section titled “4.6 Worked Example: System with Infinitely Many Solutions”

Problem. Solve the system:

x1+2x2x3+3x4=12x1+4x2x3+5x4=2x1+2x2+x3+x4=0\begin{aligned} x_1 + 2x_2 - x_3 + 3x_4 &= 1 \\ 2x_1 + 4x_2 - x_3 + 5x_4 &= 2 \\ x_1 + 2x_2 + x_3 + x_4 &= 0 \end{aligned}

Solution

(121312415212110)R22R1,R3R1(121310011000221)\begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 2 & 4 & -1 & 5 & 2 \\ 1 & 2 & 1 & 1 & 0 \end{pmatrix} \xrightarrow{R_2 - 2R_1, R_3 - R_1} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 2 & -2 & -1 \end{pmatrix}

R32R2(121310011000001)\xrightarrow{R_3 - 2R_2} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 0 & 0 & -1 \end{pmatrix}

The last row reads 0=10 = -1 So the system is inconsistent (no solution).

Revised problem: Change the last equation to x1+2x2+x3+x4=2x_1 + 2x_2 + x_3 + x_4 = 2:

(121312415212112)R22R1,R3R1(121310011000221)\begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 2 & 4 & -1 & 5 & 2 \\ 1 & 2 & 1 & 1 & 2 \end{pmatrix} \xrightarrow{R_2 - 2R_1, R_3 - R_1} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 2 & -2 & 1 \end{pmatrix}

R32R2(121310011000001)\xrightarrow{R_3 - 2R_2} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 0 & 0 & 1 \end{pmatrix}

Still inconsistent! The RREF reveals 0=10 = 1 in the last row.

Revised again: Change the last equation to x1+2x2+x3+x4=1x_1 + 2x_2 + x_3 + x_4 = 1:

(121312415212111)R22R1,R3R1(121310011000220)\begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 2 & 4 & -1 & 5 & 2 \\ 1 & 2 & 1 & 1 & 1 \end{pmatrix} \xrightarrow{R_2 - 2R_1, R_3 - R_1} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 2 & -2 & 0 \end{pmatrix}

R32R2(121310011000000)\xrightarrow{R_3 - 2R_2} \begin{pmatrix} 1 & 2 & -1 & 3 & 1 \\ 0 & 0 & 1 & -1 & 0 \\ 0 & 0 & 0 & 0 & 0 \end{pmatrix}

Now the system is consistent. Pivots in columns 1 and 3; free variables are x2x_2 and x4x_4. From row 2: x3=x4x_3 = x_4. From row 1: x1=12x2+x33x4=12x22x4x_1 = 1 - 2x_2 + x_3 - 3x_4 = 1 - 2x_2 - 2x_4.

Solution set: {(12s2t,s,t,t):s,tR}\{(1 - 2s - 2t, s, t, t) : s, t \in \mathbb{R}\}.

In parametric form: (x1x2x3x4)=(1000)+s(2100)+t(2011)\begin{pmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \end{pmatrix} = \begin{pmatrix} 1 \\ 0 \\ 0 \\ 0 \end{pmatrix} + s\begin{pmatrix} -2 \\ 1 \\ 0 \\ 0 \end{pmatrix} + t\begin{pmatrix} -2 \\ 0 \\ 1 \\ 1 \end{pmatrix}.

The solution space is a 2-dimensional affine subspace (a plane) in R4\mathbb{R}^4. \blacksquare

  • Partial pivoting is not optional for numerical work. Without it, Gaussian elimination can produce catastrophically wrong results due to rounding errors.
  • The normal equations can be ill-conditioned. For better numerical stability, use QR decomposition to solve least squares problems instead of forming ATAA^T A.
  • Not every system has a solution. Always check consistency via the Rouche—Capelli theorem before attempting to solve.
  • When a system has infinitely many solutions, the solution set is an affine subspace, not a vector space. The general solution is x=xp+xh\mathbf{x} = \mathbf{x}_p + \mathbf{x}_h where xp\mathbf{x}_p is a particular solution and xh\mathbf{x}_h is any element of the null space. The null space is a vector space, but the affine shift by xp\mathbf{x}_p means the solution set does not contain 0\mathbf{0} (unless xp=0\mathbf{x}_p = \mathbf{0}).
  • Do not confuse the number of equations with the number of unknowns. A system with more equations than unknowns (overdetermined) may have no solution, exactly one solution, or infinitely many solutions. A system with fewer equations than unknowns (underdetermined) may have no solution or infinitely many solutions, but never exactly one solution.

4.8 Intuition: What Does Gaussian Elimination Do Geometrically?

Section titled “4.8 Intuition: What Does Gaussian Elimination Do Geometrically?”

Each elementary row operation corresponds to a geometric operation on the system of equations. In R3\mathbb{R}^3, each equation a1x+a2y+a3z=ba_1 x + a_2 y + a_3 z = b defines a plane. The solution to the system is the intersection of all these planes.

  • Swapping rows reorders the equations, which does not change the solution set.
  • Multiplying a row by a scalar rescales an equation without changing its solution set.
  • Adding a multiple of one row to another replaces one plane with a new plane that passes through the line of intersection of the two original planes.

Gaussian elimination systematically rotates and translates the planes so that their intersection becomes apparent. After reduction to row echelon form, the last equation involves only one variable, the second-to-last involves at most two variables, and so on. Back substitution then recovers all variables one at a time, starting from the simplest equation.

When the system is inconsistent, the row reduction produces a contradiction (such as 0=10 = 1), meaning the planes have no common point of intersection. When there are free variables, the planes intersect in a line, plane, or higher-dimensional flat, reflecting the infinitely many solutions.

Problem. Solve the system:

x1+x2+x3+x4=102x1+3x2+x3+2x4=19x1+2x2+3x3+x4=163x1+x2+2x3+3x4=23\begin{aligned} x_1 + x_2 + x_3 + x_4 &= 10 \\ 2x_1 + 3x_2 + x_3 + 2x_4 &= 19 \\ x_1 + 2x_2 + 3x_3 + x_4 &= 16 \\ 3x_1 + x_2 + 2x_3 + 3x_4 &= 23 \end{aligned}

Solution

Augmented matrix:

(111110231219123116312323)\begin{pmatrix} 1 & 1 & 1 & 1 & 10 \\ 2 & 3 & 1 & 2 & 19 \\ 1 & 2 & 3 & 1 & 16 \\ 3 & 1 & 2 & 3 & 23 \end{pmatrix}

R22R1R_2 - 2R_1, R3R1R_3 - R_1, R43R1R_4 - 3R_1:

(111110011010120602107)\begin{pmatrix} 1 & 1 & 1 & 1 & 10 \\ 0 & 1 & -1 & 0 & -1 \\ 0 & 1 & 2 & 0 & 6 \\ 0 & -2 & -1 & 0 & -7 \end{pmatrix}

R3R2R_3 - R_2, R4+2R2R_4 + 2R_2:

(111110011010030700309)\begin{pmatrix} 1 & 1 & 1 & 1 & 10 \\ 0 & 1 & -1 & 0 & -1 \\ 0 & 0 & 3 & 0 & 7 \\ 0 & 0 & -3 & 0 & -9 \end{pmatrix}

R4+R3R_4 + R_3:

(111110011010030700002)\begin{pmatrix} 1 & 1 & 1 & 1 & 10 \\ 0 & 1 & -1 & 0 & -1 \\ 0 & 0 & 3 & 0 & 7 \\ 0 & 0 & 0 & 0 & -2 \end{pmatrix}

The last row gives 0=20 = -2, so the system is inconsistent (no solution).

Check: The rank of the coefficient matrix is 3 (three pivots), but the rank of the augmented matrix is 4 (four pivots). By the Rouche—Capelli theorem, the system is inconsistent. \blacksquare


Gaussian elimination is the systematic process of untangling a web of simultaneous constraints. Each equation in a linear system defines a hyperplane in some high-dimensional space, and a solution is a point where all hyperplanes intersect. Row reduction is the algebraic equivalent of rotating and sliding these hyperplanes until they reveal their intersection evidently. When you swap rows, you are re-ordering which constraint you address first. When you multiply a row by a scalar, you are rescaling a constraint without changing the solution set. When you add a multiple of one row to another, you are using one equation to eliminate a variable from another — the same logic as solving two equations with two unknowns by substitution.

The deeper insight is that row reduction preserves the solution space while simplifying its description. The row echelon form makes the structure of the solution set transparent: pivot columns identify the dependent variables, free columns identify the independent degrees of freedom, and the rank tells you the dimension of the solution space. This is why the same technique extends to function spaces and operator theory, where infinite-dimensional systems of equations arise logically.

flowchart TD
A[4_Systems Of Linear Equations] --> B[Key Concepts]
A --> C[Core Principles]
A --> D[Practical Applications]
B --> E[Fundamental definitions]
C --> F[Design patterns]
D --> G[Real-world usage]
  • Matrices: The coefficient matrix of a linear system determines its solvability via rank and determinant.
  • Linear Transformations: A system Ax=bA\mathbf{x} = \mathbf{b} can be viewed as finding the preimage of b\mathbf{b} under the linear transformation defined by AA.
  • Singular Value Decomposition: The pseudoinverse derived from the SVD provides the minimum-norm least squares solution to inconsistent systems.