The sum computed from lowest to highest is more accurate; it differs from the exact result by about 1 ULP, while the sum computed from highest to lowest differs by about 7 ULP.
It is erroneous to compare the sums for 1000 terms to the infinite sum. The difference between the exact mathematical sum of the first 1000 terms and the infinite sum is much larger than the error that occurs in computing the former sum. The three sums of 1000 terms (exact mathematical, from lowest to highest, from highest to lowest) are within 8 ULP of each other, while the sum of the infinite series is 4.5 trillion ULP higher.
(Additionally, the estimate for π2/6 is inaccurate. Your program has 1.644934066848226. In IEEE 754 basic 64-bit binary floating-point (which I will use for this answer), that rounds to exactly 1.6449340668482259619764818125986494123935699462890625. However, 1.6449340668482264060656916626612655818462371826171875 is closer to π2/6.)
The exact mathematical sum of the first 1000 terms is near 1.6439345666815598031390580238222155896521034464937. This was calculated with extended precision using Maple. The closest representable value to that is 1.6439345666815599056320706949918530881404876708984375. I will call this the best sum, as it is the closest possible any computed sum could be to the exact mathematical value, since no representable value is closer.
The sum computed from highest to lowest is 1.643934566681561459944305170211009681224822998046875. This differs from the best sum by 1.5543122344752191565930843353271484375e-15, which is 7 ULP. (An ULP is the smallest amount by which a representable value may be adjusted upward; it is the step size of the representable values. The ULP is a function of the magnitude of a number; it is larger for larger numbers.) A difference of 7 ULP means the number is 7 steps away from the best sum.
The sum computed from lowest to highest is 1.643934566681559683587465769960545003414154052734375. This differs from the best sum by -2.220446049250313080847263336181640625e-16, which is 1 ULP in the other direction (it is below the best sum).
Thus, the sum computed from lowest to highest is more accurate.
The infinite sum is 4.5 trillion ULP higher.
So, relative to the best sum, the numbers are in this order:
- The sum computed from lowest to highest is at −1 ULP.
- The best sum is the reference point, at 0 ULP.
- The sum computed from highest to lowest is at +7 ULP.
- π2/6 is at 4.5 trillion ULP.
Now it is clear that the sum computed from lowest to highest is farther from π2/6 because it is on the other side of the best sum. But it is closer to the best sum.
In any case, there is no absolute rule that computing a sum from lowest term to highest term produces the best answer. This is a general guideline, based on the notion that errors are smaller while numbers are smaller.
Every time you add two numbers in floating-point, there may be a small error, as the exact mathematical result must be rounded to a representable value. The errors are always at most ½ ULP of the result (because, if a representable value is more than ½ ULP from the exact mathematical result, then the next representable value in the correct direction is closer than ½ ULP).
However, the errors can vary between 0 and ½ ULP, and they can also be positive or negative. Suppose you add a series of random numbers. It is possible that, while adding numbers from highest to lowest, we will encounter a mix of positive and negative errors that just happen to largely cancel out, producing a final result near the exact mathematical result by chance. At the same time, adding numbers from lowest to highest might happen to encounter a lot of positive errors, thus accumulating into a large error.
Adding numbers of the same sign from lowest magnitude to highest magnitude tends to produce a better result, but it is not an absolute rule.
Also, if the numbers are of mixed signs, it may be advantageous to choose which numbers to add to keep the running sum near zero, rather than always choosing the next number of the lowest magnitude.