Here, ∑j=i+1naij(i−1)xj is the contribution of the already-solved unknowns xi+1,…,xn to row i.
Pivoting
Pivoting is interchanging rows to place a useful entry in the pivot position. It only reorders rows, so the system produced is still equivalent to the original.
Partial pivoting
At stage i, scan column i from row i to row n, and swap the row with the largest absolute entry into row i before eliminating.
Using the largest available entry as the pivot keeps the multipliers aii(i)aji(i) at or below 1 in size, which stops them from amplifying rounding error.
Scaled partial pivoting
Partial pivoting alone can still pick a poor pivot if rows are scaled very differently, since an entry can be large only because its whole row has large entries.
Scaled partial pivoting corrects for this. For candidate entry aji(i), compute the scale factor
sj=kmax∣ajk∣
then choose the row maximizing sj∣aji(i)∣ instead of the raw entry ∣aji(i)∣. This picks the pivot largest relative to its own row, not largest in absolute terms.
s2∣a21∣ is larger, so exchange R1↔R2. Gauss elimination on the reordered system gives x1=10.00 and x2=1.000.
Pitfalls
Zero pivot
If aii(i)=0 at any stage, the elimination formula divides by zero, even though the system may still have a unique solution.
Small pivot
A pivot that is small rather than zero doesn’t stop the algorithm, but dividing by it inflates the multipliers aii(i)aji(i). This amplifies rounding error already present in aji(i) and bj(i), which then propagates through every later stage and into back substitution.
Ill conditioning
A problem is ill-conditioned iff a small change in any of its elements causes a large change in its solution. Otherwise the problem is well-conditioned.
Round-off errors effectively change the elements of A and b slightly. If the system is ill-conditioned, these small changes produce large errors in the solution.
If A is close to singular, small errors in the input data or in rounding get magnified into large errors in x, even with pivoting. Pivoting controls error growth from the algorithm itself, but cannot fix a system that is inherently sensitive to small changes in its input.
Consider
(1111.0001)(xy)=(22.0001)
with solution x=1,y=1. Changing b2 from 2.0001 to 2.0002, a change of 0.0001, gives
(1111.0001)(xy)=(22.0002)
with solution x=0,y=2. A 0.0001 change in b2 moved x by 1 and y by 1. No amount of pivoting prevents this, since the coefficient matrix itself is nearly singular, det(1111.0001)=0.0001.
Condition Number
A measure of the degree of ill-conditioning. Denoted as κ(A). Defined as:
κ(A)=∥A∥∥A−1∥
A large κ(A) means A is close to singular, and small errors in b or in rounding get magnified into large errors in x.
{x+y=2x+1.001y=2{x+y=2x+1.001y=2.001
The left system has solution x=2, y=0. The right system, obtained by a 0.001 change in one constant, has solution x=1, y=1. The coefficient matrix is ill-conditioned, with condition number 4004.
Cost
Method
Time
Space
Forward elimination
O(n3)
O(n2)
Back substitution
O(n2)
O(n2)
Space is O(n2) for both, for storing the augmented matrix [A∣b]. Elimination is done in place, so no extra storage proportional to n2 is needed beyond this.
The O(n3) time cost of forward elimination makes Gaussian elimination unsuitable for repeatedly solving Ax=b for many different b with the same A.