Numerical Solution of Linear Systems

Circuit node voltages, truss member forces and temperatures on a heated plate all lead to the same task: solving a system of linear equations Ax=bA\mathbf{x} = \mathbf{b}, where AA is an n×nn \times n matrix of known coefficients, b\mathbf{b} is a known right-hand side and x\mathbf{x} holds the unknowns. Substitution works for two or three equations by hand, but real models have hundreds or millions of unknowns and run on computers that round results. You need algorithms that are systematic, efficient and stable under rounding. We focus on nonsingular systems, which have a unique solution, using direct elimination or iteration.

Gaussian elimination and back substitution

Gaussian elimination reduces the system to an equivalent upper-triangular one by subtracting multiples of one row from the rows below it. Working on the augmented matrix [A∣b][A \mid \mathbf{b}] column by column, you clear each entry below the diagonal entry akka_{kk}, called the pivot:


mik=aikakk,rowi←rowi−mik rowk(i=k+1,…,n)m_{ik} = \frac{a_{ik}}{a_{kk}}, \qquad \text{row}_i \leftarrow \text{row}_i - m_{ik}\,\text{row}_k \quad (i = k+1, \dots, n)


These row operations do not change the solution. Once the matrix is triangular, back substitution solves the last equation first and works upward:


xi=1uii(ci−∑j=i+1nuij xj),i=n,n−1,…,1x_i = \frac{1}{u_{ii}}\left(c_i - \sum_{j=i+1}^{n} u_{ij}\,x_j\right), \qquad i = n, n-1, \dots, 1


where uiju_{ij} and cic_i are the entries of the triangular system.


Elimination costs about 23n3\tfrac{2}{3}n^3 flops, while back substitution costs only about n2n^2. Elimination dominates, and doubling nn multiplies its cost by about eight.


Example: A dense system with n=1000n = 1000 needs roughly 23(1000)3≈6.7×108\tfrac{2}{3}(1000)^3 \approx 6.7 \times 10^8 flops for elimination but only about 10610^6 for back substitution.

Pivoting and checking the answer

A zero pivot makes the multiplier undefined. A pivot tiny relative to other entries in its column can produce huge multipliers and amplify rounding errors. Partial pivoting reduces this risk. Before clearing column kk, swap in the row at or below row kk whose entry in column kk has the largest absolute value. With a nonzero selected pivot, every multiplier satisfies ∣mik∣≤1|m_{ik}| \le 1 in exact arithmetic. Bounded multipliers reduce one source of instability, but do not prevent matrix entries from growing or rounding errors from being amplified.


For a nonsingular matrix, partial pivoting supplies nonzero pivots in exact arithmetic. If every eligible entry in a pivot column is zero, no row swap can supply a nonzero pivot: the matrix is singular, and this unique-solution procedure cannot continue.



After solving, compute the residual r=b−Ax~\mathbf{r} = \mathbf{b} - A\tilde{\mathbf{x}} for your computed solution x~\tilde{\mathbf{x}}. Assess its size relative to the scales of the coefficients, solution and right-hand side, using the solver's requested tolerance. An unexpectedly large residual on that basis warrants investigating arithmetic, code or convergence; its absolute magnitude alone does not establish an error. A small residual relative to these scales means the equations are nearly satisfied, but a small residual does not guarantee a small error when the system is ill-conditioned.

Iterative methods: Jacobi and Gauss–Seidel

For large systems in which most coefficients are zero, elimination can consume time and memory by filling in entries that started as zero. Iterative methods instead start from a guess x(0)\mathbf{x}^{(0)} and update it sweep by sweep. The Jacobi method solves equation ii for xix_i using only values from the previous sweep:


xi(k+1)=1aii(bi−∑j≠iaij xj(k))x_i^{(k+1)} = \frac{1}{a_{ii}}\left(b_i - \sum_{j \ne i} a_{ij}\,x_j^{(k)}\right)


The Gauss–Seidel method uses the same rearrangement but substitutes each new xjx_j as soon as it is computed, so it often converges in fewer sweeps. Both methods converge from any starting guess when AA is strictly diagonally dominant by rows:


∣aii∣>∑j≠i∣aij∣for every row i|a_{ii}| > \sum_{j \ne i} |a_{ij}| \quad \text{for every row } i


This condition is sufficient, not necessary; some systems that fail it still converge. Stop when an appropriately scaled residual meets the chosen tolerance; changes between sweeps can provide an additional check.



Feature

Gaussian elimination

Jacobi and Gauss–Seidel

Result

Exact solution after a fixed number of steps in exact arithmetic

Successive approximations that approach the solution when convergence holds

Cost

About 23n3\tfrac{2}{3}n^3 flops

About 2n22n^2 flops per sweep for a dense matrix, far fewer when most entries are zero

Requirement

Nonsingular matrix; partial pivoting supplies nonzero pivots in exact arithmetic

Nonzero diagonal entries and convergence conditions, such as strict row diagonal dominance

Best suited to

Small to medium dense systems

Large sparse systems when convergence is suitable


What to remember

  • Gaussian elimination makes the system upper triangular; back substitution solves it from the bottom up. Elimination costs about 23n3\tfrac{2}{3}n^3 flops.
  • Partial pivoting moves whole rows, including b\mathbf{b}, and bounds multiplier magnitudes by 1 in exact arithmetic. It reduces instability but cannot guarantee freedom from rounding-error amplification or rescue a singular system.
  • Check the residual against the problem scale and requested tolerance. A small residual is not proof of a small solution error.
  • Jacobi uses previous-sweep values; Gauss–Seidel uses the newest values. Strict row diagonal dominance guarantees that both converge.

Example: Solving a 3 × 3 system with partial pivoting

A program you are testing must solve the system below. Work it by hand so you can compare your result with the program's output. All arithmetic here is exact in decimals, so carry every value exactly.


x+2y+z=34x+y−2z=12x+3y+4z=13\begin{aligned} x + 2y + z &= 3 \\ 4x + y - 2z &= 1 \\ 2x + 3y + 4z &= 13 \end{aligned}


a) Use Gaussian elimination with partial pivoting to reduce the system to upper-triangular form. Record every row swap.


Column 1 holds the entries 1, 4 and 2. The largest in absolute value is 4, in row 2, so swap rows 1 and 2:


[41−21121323413]\left[\begin{array}{ccc|c} 4 & 1 & -2 & 1 \\ 1 & 2 & 1 & 3 \\ 2 & 3 & 4 & 13 \end{array}\right]


The multiplier for row 2 is 1/41/4 = ________ and the multiplier for row 3 is 2/42/4 = ________. Subtract those multiples of row 1:

  • Row 2: [1, 2, 1∣3]−0.25 [4, 1, −2∣1]=[0, 1.75, 1.5∣2.75][1,\ 2,\ 1 \mid 3] - 0.25\,[4,\ 1,\ -2 \mid 1] = [0,\ 1.75,\ 1.5 \mid 2.75]
  • Row 3: [2, 3, 4∣13]−0.5 [4, 1, −2∣1]=[0, 2.5, 5∣12.5][2,\ 3,\ 4 \mid 13] - 0.5\,[4,\ 1,\ -2 \mid 1] = [0,\ 2.5,\ 5 \mid 12.5]

In column 2, the entries on and below the diagonal are 1.75 and 2.5, so the new pivot is ________ and rows 2 and 3 swap. The multiplier for the remaining row is 1.75/2.51.75/2.5 = ________:


[0, 1.75, 1.5∣2.75]−0.7 [0, 2.5, 5∣12.5]=[0, 0, −2∣−6][0,\ 1.75,\ 1.5 \mid 2.75] - 0.7\,[0,\ 2.5,\ 5 \mid 12.5] = [0,\ 0,\ -2 \mid -6]


The upper-triangular system is


4x+y−2z=12.5y+5z=12.5−2z=−6\begin{aligned} 4x + y - 2z &= 1 \\ 2.5y + 5z &= 12.5 \\ -2z &= -6 \end{aligned}


Two swaps were made: rows 1 and 2 for column 1, then rows 2 and 3 for column 2. Every multiplier (0.25, 0.5 and 0.7) has magnitude at most 1, as partial pivoting guarantees.


b) Use back substitution to find xx, yy and zz.


Start with the last equation: −2z=−6-2z = -6, so z=3z = 3.


Substitute into the second equation: 2.5y+5(3)=12.52.5y + 5(3) = 12.5, so 2.5y=12.5−152.5y = 12.5 - 15 = ________ and y=−1y = -1.


Substitute both into the first equation: 4x+(−1)−2(3)=14x + (-1) - 2(3) = 1, so 4x=1+1+64x = 1 + 1 + 6 = ________ and x=2x = 2.


The solution is x=2x = 2, y=−1y = -1, z=3z = 3. As a quick check, the original first equation gives 2+2(−1)+3=32 + 2(-1) + 3 = 3, which matches its right-hand side.


c) A classmate's code reports x~=(2.1, −1.0, 2.9)\tilde{\mathbf{x}} = (2.1,\ -1.0,\ 2.9). Compute the residual r=b−Ax~\mathbf{r} = \mathbf{b} - A\tilde{\mathbf{x}} using the original equations, and say what it tells you.


Evaluate each original left-hand side at x~\tilde{\mathbf{x}}:

  • Equation 1: 2.1+2(−1.0)+2.9=3.02.1 + 2(-1.0) + 2.9 = 3.0
  • Equation 2: 4(2.1)+(−1.0)−2(2.9)=8.4−1.0−5.84(2.1) + (-1.0) - 2(2.9) = 8.4 - 1.0 - 5.8 = ________
  • Equation 3: 2(2.1)+3(−1.0)+4(2.9)=4.2−3.0+11.62(2.1) + 3(-1.0) + 4(2.9) = 4.2 - 3.0 + 11.6 = ________

Subtract each from its right-hand side:


r=[3−3.01−1.613−12.8]=[0−0.60.2]\mathbf{r} = \begin{bmatrix} 3 - 3.0 \\ 1 - 1.6 \\ 13 - 12.8 \end{bmatrix} = \begin{bmatrix} 0 \\ -0.6 \\ 0.2 \end{bmatrix}


The nonzero components show that x~\tilde{\mathbf{x}} is not an exact solution. Nonzero residuals can arise from rounding or an iterative method's stopping tolerance, so compare the residual size with the required accuracy before concluding that the code is faulty. The zero first component is a warning against checking only one equation: x~\tilde{\mathbf{x}} differs from the true solution by (0.1, 0, −0.1)(0.1,\ 0,\ -0.1), yet it satisfies equation 1 exactly.

Match each term used in numerical methods for solving Ax=bA\mathbf{x} = \mathbf{b} with the description that defines it.

Match each term
A.

Swapping rows so the largest-magnitude entry in the current column, among rows at or below the current pivot row, becomes the divisor

B.

Each diagonal entry's magnitude exceeds the sum of the magnitudes of the other entries in its row

C.

The diagonal entry divided into the entries below it to form the elimination multipliers

D.

An iteration that updates every unknown using only values from the previous sweep

E.

Solving an upper-triangular system from the last equation up to the first

F.

The vector b−Ax~\mathbf{b} - A\tilde{\mathbf{x}} computed for an approximate solution x~\tilde{\mathbf{x}}

G.

An iteration that uses each newly computed unknown immediately within the same sweep

Jacobi method

Strict diagonal dominance

Gauss–Seidel method

Partial pivoting

Pivot

Residual

Back substitution

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Arrange these stages of solving a dense linear system Ax=bA\mathbf{x} = \mathbf{b} by Gaussian elimination with partial pivoting in the order a program carries them out.

  1. 1.

    Divide each entry below the pivot by the pivot to get the multipliers.

  2. 2.

    In the current column, find the row at or below the diagonal with the largest absolute entry and swap it into the pivot position.

  3. 3.

    Compute the residual b−Ax~\mathbf{b} - A\tilde{\mathbf{x}} to check the computed solution.

  4. 4.

    Move to the next column and repeat until the matrix is upper triangular.

  5. 5.

    Subtract each multiplier times the pivot row from its row, including the right-hand-side entry.

  6. 6.

    Form the augmented matrix [A∣b][A \mid \mathbf{b}].

  7. 7.

    Solve for the unknowns by back substitution, starting with the last equation.

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A numerical solver applies valid row operations to three separate linear systems with real-valued unknowns xx and yy. The resulting equations below contain exact coefficients rather than rounded approximations. Complete each classification using exactly one of these labels: no solution, infinitely many solutions, or unique solution.


System P becomes


x+2y=6,0x+0y=3.\begin{aligned} x+2y&=6,\\ 0x+0y&=3. \end{aligned}


System P has .


System Q becomes


x+2y=6,0x+0y=0.\begin{aligned} x+2y&=6,\\ 0x+0y&=0. \end{aligned}


System Q has .


System R becomes


x+2y=6,3y=6.\begin{aligned} x+2y&=6,\\ 3y&=6. \end{aligned}


System R has a .

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

Extra Practice