Gaussian Elimination Calculator
Enter a square system Ax = b by writing the n × n matrix A into the first n columns, and the n × 1 vector b into the rightmost column. Blank cells count as zero.
Working
How it works
This is an implementation of Gaussian elimination, which you can read about here. We first transform the augmented matrix [A | b] into row echelon form using partial pivoting. Stepwise,
- Starting from the top-left, we loop through each (row, column) pair along the diagonal of the augmented matrix.
- Each iteration, we search through rows below us along our column.
- After finding the row with the highest seen entry by magnitude, we swap with that entire row.
- To normalize, we divide the (new) current row by the pivot element.
- Finally, to eliminate, we subtract multiples of the current row from all rows below to zero out our column.
This algorithm allows us to avoid division by zero or significant numerical rounding errors (although if the pivot element is near or at zero, the matrix is singular and the system admits either no solutions or infinitely many). Because we now have an upper triangular matrix, we can use back substitution to solve for xn first and then recursively work upward.
The source is a direct port of a short Python implementation using NumPy.