The Thomas algorithm computes the solution of a tridiagonal system whose leading principal minors are nonzero full
This proof shows: correctness, termination.
A is tridiagonal of order n, with subdiagonal a2,…,an, diagonal b1,…,bn and superdiagonal c1,…,cn−1. Let Ak=A1:k,1:k and δk=detAk, with δ0=1. The loops have fixed lengths, so the algorithm stops; it stops early, at line L3 or L6, exactly when some pivot is zero.
Lemma 1 (the pivots). If δ1,…,δk−1 are nonzero, then lines L1 to L4 compute u1,…,uk with ui=δi/δi−1 for i≤k.
Proof. Expanding detAi along its last row gives the three-term recurrence δi=biδi−1−aici−1δi−2 for i≥2, with δ1=b1. For i=1, u1=b1=δ1/δ0. For i≥2, assume ui−1=δi−1/δi−2, which is nonzero. Line L3 gives li=ai/ui−1 and line L4 gives
ui=bi−ui−1aici−1=bi−δi−1aici−1δi−2=δi−1biδi−1−aici−1δi−2=δi−1δi.□ So no division by zero occurs if and only if δ1,…,δn−1 are nonzero, and un=0 if and only if moreover detA=δn=0.
Lemma 2 (the factorization). If all pivots are nonzero, then A=LU, where L is unit lower bidiagonal with Li,i−1=li and U is upper bidiagonal with Uii=ui and Ui,i+1=ci.
Proof. The product LU is tridiagonal. Its entry (1,1) is u1=b1. For i≥2, row i of L has li in column i−1 and 1 in column i, so (LU)i,i−1=liui−1=ai, (LU)ii=lici−1+ui=bi by line L4, and (LU)i,i+1=ci. □
Lemma 3 (the sweeps). Line L5 computes the solution y of Ly=d, and lines L6 and L7 compute the solution x of Ux=y.
Proof. Row i of Ly=d is liyi−1+yi=di (with no first term for i=1), which is lines L1 and L5. Row i of Ux=y is uixi+cixi+1=yi (with no second term for i=n). Going from i=n down to 1, xi+1 is known when xi is computed, and lines L6 and L7 solve row i for xi, which is possible because ui=0. □
Theorem. If δ1,…,δn are nonzero, THOMAS returns the unique solution of Ax=d; otherwise it stops at the first zero pivot.
Proof. By Lemmas 2 and 3, Ax=LUx=Ly=d, and A is nonsingular because δn=0. The second claim is Lemma 1. ■
Diagonal dominance gives nonzero pivots. Suppose A is strictly diagonally dominant by rows: ∣bi∣>∣ai∣+∣ci∣ for all i, with a1=cn=0. Then ∣ui∣>∣ci∣ for all i, so no pivot is zero. Indeed ∣u1∣=∣b1∣>∣c1∣. If ∣ui−1∣>∣ci−1∣, then ∣lici−1∣=∣ai∣∣ci−1∣/∣ui−1∣≤∣ai∣, so ∣ui∣≥∣bi∣−∣lici−1∣≥∣bi∣−∣ai∣>∣ci∣. The same induction shows ∣li∣≤∣ai∣/∣ui−1∣ stays bounded, and that the pivots satisfy ∣ui∣≤∣bi∣+∣ai∣.
Floating point. Each computed quantity is one operation or one fused pair: l^i=(ai/u^i−1)(1+ϵ1), u^i=(bi−l^ici−1(1+ϵ2))(1+ϵ3), and similarly for y^i and x^i, with ∣ϵj∣≤u. Moving these factors onto the entries of L^ and U^ gives the bound ∣ΔA∣≤f(u)∣L^∣∣U^∣ with f(u)=4u+3u2+u3 stated on the page (Higham, Section 9.6). The tests check the resulting residual inequality ∣d−Ax^∣≤f(u)∣L^∣∣U^∣∣x^∣ exactly.