Neumaier summation is as accurate as summation in twice the working precision full
This proof shows: correctness.
Setting. Binary floating-point arithmetic with round to nearest (any tie rule), subnormal numbers and no overflow; u=2−p. Every addition and subtraction satisfies fl(a±b)=(a±b)(1+δ) with ∣δ∣≤u, and is exact if its result is subnormal. γk=ku/(1−ku) for ku<1, with γ0=0; γk is increasing in k.
The iteration. Let t0=0 and, for i=1,…,n, ti=fl(ti−1+xi) and qi=fl(fl(a−ti)+b), where (a,b)=(ti−1,xi) if ∣ti−1∣≥∣xi∣ and (a,b)=(xi,ti−1) otherwise. Let c0=0, ci=fl(ci−1+qi), and s^=fl(tn+cn). Let A=∑i=1n∣xi∣, s=∑i=1nxi, and assume (n−1)u<1.
Theorem. qi=ti−1+xi−ti exactly for every i, s=tn+∑i=1nqi, and
∣s^−s∣≤u∣s∣+(1+u)γn−2γn−1A. If moreover n(n−2)u≤1, then ∣s^−s∣≤u∣s∣+γn−12A.
Step 1 (exact errors). If ∣a∣≥∣b∣ then ea≥eb, so by the theorem on Fast2Sum, fl(a−ti)=a−ti and the error b−(ti−a) is a float; here the algorithm computes fl((a−ti)+b), which is that same float, so qi=a+b−ti=ti−1+xi−ti. Summing over i telescopes: ∑iqi=∑ixi+t0−tn=s−tn.
Step 2 (size of the errors). qi is the rounding error of ti=fl(ti−1+xi), so ∣qi∣≤u∣ti∣ (if ti is normal, ∣qi∣≤21ulp(ti)≤u∣ti∣; if ti is subnormal, the addition is exact and qi=0). Also q1=0, since t0=0 makes the first addition exact. The ti are the partial sums of a plain loop, and by the standard analysis of recursive summation (Higham, Section 4.2, from Lemma 3.1), ti=∑j≤ixj(1+θj(i)) with ∣θj(i)∣≤γi−1, so ∣ti∣≤(1+γi−1)∑j≤i∣xj∣≤(1+γn−1)A. Hence
Q:=i=1∑n∣qi∣=i=2∑n∣qi∣≤(n−1)u(1+γn−1)A=γn−1A, because (n−1)u(1+γn−1)=(n−1)u/(1−(n−1)u)=γn−1.
Step 3 (summing the errors). Since q1=0, c1=0 and c2=q2 exactly, and cn is a plain loop over the n−1 terms q2,…,qn, which makes n−2 rounded additions. By the same analysis, ∣cn−∑iqi∣≤γn−2Q≤γn−2γn−1A. (For n≤2 this error is 0.)
Step 4 (the final addition). Let E=cn−∑iqi. Then tn+cn=s+E by Step 1, and s^=(s+E)(1+δ) with ∣δ∣≤u. So
∣s^−s∣=∣δs+(1+δ)E∣≤u∣s∣+(1+u)∣E∣≤u∣s∣+(1+u)γn−2γn−1A. Step 5 (the simpler form). It suffices that (1+u)γn−2≤γn−1 for n≥3 (for n≤2 the left side is 0). Multiplying out with the positive denominators, this is (n−2)(1+u)(1−(n−1)u)≤(n−1)(1−(n−2)u). The left side is at most (n−2)(1+u)=n−2+(n−2)u, and the inequality n−2+(n−2)u≤n−1−(n−1)(n−2)u is equivalent to n(n−2)u≤1. □
Remark. The theorem needs no assumption on the order or the signs of the terms. It says that s^ is the rounding of a value within γn−12A (to first order, n2u2A) of s, which is what a plain loop in a format with unit roundoff u2 would guarantee, up to the constant.