I have a power series with all terms non-negative which I want to evaluate to some arbitrarily set precision p
(the length in binary digits of a MPFR floating-point mantissa). The result should be faithfully rounded. The issue is that I don't know when should I stop adding terms to the result variable, that is, how do I know when do I already have p + 32
accurate summed bits of the series? 32
is just an arbitrarily chosen small natural number meant to facilitate more accurate rounding to p
binary digits.
This is my original series
0 <= h <= 1
series_orig(h) := sum(n = 0, +inf, a(n) * h^n)
But I actually need to calculate an arbitrary derivative of the above series (m
is the order of the derivative):
series(h, m) := sum(n = m, +inf, a(n) * (n - m + 1) * ... * n * h^(n - m))
The rational number sequence a
is defined like so:
a(n) := binomial(1/2, n)^2
= (((2*n)!/(n!)) / (n! * 4^n * (2*n - 1)))^2
So how do I know when to stop summing up terms of series
?
Is the following maybe a good strategy?
- compute in
p * 4
(which is assumed to be greater thanp + 32
). - at each point be able to recall the current partial sum and the previous one.
- stop looping when the previous and current partial sums are equal if rounded to precision
p + 32
. - round to precision
p
and return.
Clarification
I'm doing this with MPFI, an interval arithmetic addon to MPFR. Thus the [mpfi] tag.
Attempts to get relevant formulas and equations
Guided by Eric in the comments, I have managed to derive a formula for the required working precision and an equation for the required number of terms of the series in the sum.
A problem, however, is that a nice formula for the required number of terms is not possible.
Someone more mathematically capable might instead be able to achieve a formula for a useful upper bound, but that seems quite difficult to do for all possible requested result precisions and for all possible values of m
(the order of the derivative). Note that the formulas need to be easily computable so they're ready before I start computing the series.
Another problem is that it seems necessary to assume the worst case for h
(h = 1
) for there to be any chance of a nice formula, but this is wasteful if h
is far from the worst case, that is if h
is close to zero.