The Faddeev-LeVerrier recurrence returns the characteristic polynomial and M_n full
This proof shows: correctness, termination.
Let R be a commutative ring in which the integers 1,2,…,n are invertible, for example a field of characteristic 0 or of characteristic greater than n, and let A be an n×n matrix over R. Write
χA(x)=det(xI−A)=k=0∑npkxn−k,p0=1, so that pk is the coefficient of xn−k, the same indexing as the pseudocode. The case of the integers is treated at the end.
Claim. FADDEEV-LEVERRIER(A) stops, returns (p0,…,pn), and returns a matrix Mn with AMn=−pnI and adj(A)=(−1)n−1Mn for n≥1.
Termination. Line L2 runs k over n values, and each of lines L3 to L5 is a finite computation.
Lemma 1 (the adjugate of xI−A). Let B(x)=adj(xI−A), a matrix over R[x]. Define matrices M1,…,Mn by M1=I and Mk+1=AMk+pkI for 1≤k≤n−1. Then B(x)=∑k=1nMkxn−k, and AMn+pnI=0.
Proof. Each entry of B(x) is, up to sign, a minor of order n−1 of xI−A, so it has degree at most n−1. Write B(x)=∑k=1nBkxn−k with Bk∈Rn×n. By Cramer's rule over the commutative ring R[x], (xI−A)B(x)=χA(x)I. Comparing the coefficients of xn,xn−1,…,x0:
- xn: B1=p0I=I.
- xn−k for 1≤k≤n−1: Bk+1−ABk=pkI.
- x0: −ABn=pnI.
So the Bk satisfy the same recurrence as the Mk with the same start, hence Bk=Mk for all k, and AMn+pnI=0. □
Lemma 2 (derivative of the determinant). χA′(x)=trB(x), where ′ is the formal derivative in R[x].
Proof. Write χA(x)=∑σsgn(σ)∏i(xI−A)i,σ(i). The formal derivative satisfies the product rule, and the derivative of the entry (xI−A)ij is 1 if i=j and 0 otherwise. So χA′(x)=∑idetNi(x), where Ni(x) is xI−A with row i replaced by the unit row eiT. Expanding detNi(x) along row i gives the cofactor of the entry (i,i) of xI−A, which is the diagonal entry B(x)ii of the adjugate. Summing over i gives trB(x). □
Lemma 3 (the trace recurrence). For 1≤k≤n, kpk=−tr(AMk).
Proof. The coefficient of xn−k in χA′(x)=∑j(n−j)pjxn−j−1 is (n−k+1)pk−1. By Lemmas 1 and 2, it is also trMk. So trMk=(n−k+1)pk−1 for 1≤k≤n, and the same formula with k+1 gives trMk+1=(n−k)pk for k≤n−1.
For k≤n−1, take the trace of Mk+1=AMk+pkI: (n−k)pk=tr(AMk)+npk, so kpk=−tr(AMk). For k=n, take the trace of AMn+pnI=0: tr(AMn)+npn=0, which is the same formula. □
Invariant. At the start of the iteration of line L2 with index k, the stored values p0,…,pk−1 are the coefficients of χA and N=AMk−1, where we put M0=0.
Initialization. For k=1, line L1 set p0=1 and N=0=AM0.
Maintenance. Line L3 sets M=N+pk−1I=AMk−1+pk−1I. For k=1 this is 0+I=M1, and for k≥2 it is Mk by the recurrence of Lemma 1. Line L4 sets N=AMk. Line L5 sets pk=−tr(AMk)/k, which is the coefficient pk by Lemma 3, since k is invertible. So the invariant holds for k+1.
End. After the iteration with k=n, the list holds p0,…,pn, and M=Mn; line L6 returns them. For n=0 the loop is empty and the result is (1), the characteristic polynomial of the empty matrix. By Lemma 1, AMn=−pnI. Since B(0)=Mn and B(0)=adj(−A)=(−1)n−1adj(A) (each cofactor is a minor of order n−1), adj(A)=(−1)n−1Mn.
Integers. Let R=Z. Run the argument in Q, where 1,…,n are invertible: the computed pk and Mk are the coefficients of χA and of adj(xI−A), which have integer entries because they are integer combinations of minors of A. So every quotient on line L5 is an integer, and the exact integer division of the implementation computes it. ■
Remark. If some k≤n is not invertible in R, Lemma 3 still holds but does not determine pk. Over Z/2Z with n=2, the equation 2p2=−tr(AM2) reads 0=0 for every matrix, so the method has no way to find detA.