Solve a linear system by forward elimination with partial (maximum absolute value) pivoting, then back substitution. Example: [[1,2|4],[2,1|5]] → x1=2, x2=1.

Forward elimination produces an upper triangular system; back substitution then solves for the unknowns.

Example

Use a pivot swap and row operations to solve the system.

highlighted = computed this step

Step 1 — Set up

Start with the augmented matrix.

[124215]\left[\begin{array}{cc|c}1&2&4\\2&1&5\end{array}\right]

Step 2 — Pivot swap

Swap rows 1 and 2 so the largest pivot is on top.

[215124]\left[\begin{array}{cc|c}\hlmath{2}&\hlmath{1}&\hlmath{5}\\\hlmath{1}&\hlmath{2}&\hlmath{4}\end{array}\right]

Step 3 — Eliminate below

Eliminate below the pivot: R2 gets R2 minus R1 over 2.

[21503232]\left[\begin{array}{cc|c}2&1&5\\\hlmath{0}&\hlmath{\frac{3}{2}}&\hlmath{\frac{3}{2}}\end{array}\right]

Step 4 — Normalize row 2

Scale row 2 by 2 over 3.

[215011]\left[\begin{array}{cc|c}2&1&5\\\hlmath{0}&\hlmath{1}&\hlmath{1}\end{array}\right]

Step 5 — Back substitute

Use row 2 to eliminate x2 from row 1.

[204011]\left[\begin{array}{cc|c}\hlmath{2}&\hlmath{0}&\hlmath{4}\\0&1&1\end{array}\right]

Step 6 — Normalize row 1

Scale row 1 by 1 over 2.

[102011]\left[\begin{array}{cc|c}\hlmath{1}&\hlmath{0}&\hlmath{2}\\0&1&1\end{array}\right]

Step 7 — Solution

Read the solution x1 = 2 and x2 = 1.

[102011]x1=2x2=1\left[\begin{array}{cc|c}1&0&2\\0&1&1\end{array}\right] \quad x_ 1 = \hl{2} \quad x_ 2 = \hl{1}
gaussian-elimination-partial-pivoting Partial pivoting selects the row with the largest absolute value in the current column as the pivot, improving numerical stability.