In number theory it's common to take infinite sums of the form mu(n) * f(n). On several occasions I've seen code of the form
suminf(n=1, moebius(n)*f(n))
which looks like it would compute such a sum, but since mu(48) = mu(49) = mu(50) = 0, the sum is prematurely truncated.
It's not too hard to re-write the suminf mechanics to bypass this: get an initial estimate of the sum, scale down according to default(realprecision), and run the sum until f(n) (or f(n), f(n+1), ..., f(n+k) for some small k) is 0. But this is kind of a pain, and easy to get wrong in subtle ways. Is there a better way of doing this?
Charles Greathouse
Analyst/Programmer
Case Western Reserve University