macrakis at gmail.com wrote on 05/07/2008 10:09:55 AM:
> > but if you are having problems summing alternating series, you could
try
> > adding up the positive terms separately from the negative ones
>
> Really? I would have thought that that would be the *worst* order.
> Isn't it better to combine terms that nearly cancel first, starting
> with the smallest?
Yes, I would generally expect (sum of positive)-(sum negatives) to be
the worst order. But this ordering has one advantage over other
orders: it puts all the subtractive cancellation into a single
difference. So the cost of bounding the subtractive cancellation is
O(1) instead of O(n). If you are going to redo the calculation with a
larger value for fpprec when the error is too big, doing (sum of
positive)-(sum negatives) might be the way to go. The downside is that
you might set fpprec to a value that is larger than it needs to
be--and I suppose there is a O(fpprec^2) penalty for multiplication
and division.
Of course, increasing fpprec beyond the accuracy of the summands
doesn't work.
Barton