These are the human proofs of Paterson-Stockmeyer algorithm, at full length.
PATERSON-STOCKMEYER returns f(X) with at most 2 ceil(sqrt(n + 1)) - 2 nonscalar multiplications full
This proof shows: correctness.
Let R be a commutative ring, A an associative R-algebra with unit 1A, X∈A, and a=[a0,…,an] with n≥0 and f=∑i=0naixi. Fix a block size k≥1, let m=⌈(n+1)/k⌉, and set at=0 for t>n. Let R[X]⊆A be the set of elements g(X) for g∈R[x].
Lemma 1 (polynomials in X commute).R[X] is a commutative subring of A, and evaluation g↦g(X) is a ring homomorphism from R[x] onto R[X].
Proof. Since A is an R-algebra, (cP)(c′Q)=(cc′)(PQ) for c,c′∈R and P,Q∈A, and XiXj=Xi+j=XjXi by associativity. Expanding by distributivity, g(X)h(X)=(gh)(X)=(hg)(X)=h(X)g(X), and g(X)+h(X)=(g+h)(X). □
Lemma 2 (block decomposition). With Bj=∑i=0k−1ajk+iXi, we have f(X)=∑j=0m−1Bj(Xk)j.
Proof. Division with remainder by k maps each t∈{0,…,mk−1} to a unique pair (j,i) with t=jk+i, 0≤j<m and 0≤i<k. Since n<mk, the coefficients a0,…,an all occur, and the other terms are zero. By Lemma 1, Xi(Xk)j=Xjk+i, so ∑jBj(Xk)j=∑t<mkatXt=f(X). □
Theorem (correctness). PATERSON-STOCKMEYER returns f(X), for every block size k≥1.
Proof.Lines L2 and L3. By induction on i, Pi=Xi for 0≤i≤min(k,n), with P0=1A=X0. If m≥2, then k<n+1, so min(k,n)=k and Pk=Xk exists. In line L4 a term with jk+i≤n has i≤n and i<k, so Pi is defined. The left-out terms have ajk+i=0. So line L4 computes the Bj of Lemma 2.
Lines L5 to L7. We show that after line L7 runs for index j, and after line L5 for j=m−1, the value is S=∑t=jm−1Bt(Xk)t−j. For j=m−1, line L5 sets S=Bm−1. If the claim holds for j+1, then line L7 gives S⋅Xk+Bj=∑t=j+1m−1Bt(Xk)t−j−1Xk+Bj=∑t=jm−1Bt(Xk)t−j, using Lemma 1 to move Xk past the powers of Xk. For j=0 this is f(X) by Lemma 2, which line L8 returns. For m=1 the loop does not run and S=B0=f(X). □
Theorem (cost). For n≥1 the algorithm does min(k,n)−1+m−1 nonscalar multiplications, n+1 scalar multiplications and n additions. With k=⌈n+1⌉, the number of nonscalar multiplications is at most 2k−2≤2n+1.
Proof. Line L3 does one nonscalar product for each i from 2 to min(k,n), and line L7 does one for each j from m−2 down to 0. No other line multiplies two elements of A: line L4 multiplies the power Pi by the scalar ajk+i. Line L4 does one scalar product for each t=jk+i≤n, so n+1 in all. The additions of lines L4 and L7 each join two partial sums of the final expression ∑tatXt, which has n+1 terms, so there are n of them. For the bound, (k−1)2<n+1≤k2 by the choice of k, so (n+1)/k≤k and m≤k. Hence min(k,n)−1+m−1≤2k−2. Finally k<n+1+1, so 2k−2<2n+1. ■