Evaluate Nth root of a rational to a correctly rounded float
Excuse my lack of vocabulary for I have no formal training in this field, which is also why I ask this question - it may be trivial or it may be impossible.
I want to evaluate an expression in the following form down to a binary float with "correct" rounding and I'm worried that double-rounding will corrupt my result:
$$\sqrt[c]{\frac{a}{b}} \qquad a \in \mathbb N \quad b,c \in \mathbb N_{> 0}$$
By binary float I mostly mean a plain old double, but since I use MPFR it could have any finite precision.
By correct rounding I mean as if the complete expression is evaluated to infinite precision and then rounded correctly, without any chance of "double rounding" corrupting the result.
I use MPFR and GMP to work with these expressions using arbitrary sized integers and floats, and so far I divide the work into two steps, rounding to a larger float in between:
$$t = a/b \qquad t:\mathrm{e.g.\ binary128}$$ $$y = \sqrt[c]{t} \qquad y: \mathrm{e.g.\ binary64}$$
Using MPFR I can calculate both $a/b$ and $\sqrt[c] t$ correctly rounded to any arbitrary precision, but I don't know how to do these two steps in a way that guarantees correct rounding for the complete expression!
Here is a code example of what I'm currently doing. Since it's written in C it is a bit clumsy (no overloads or default arguments) but I hope you can see the steps even if you're not fluent in this language or the libraries I use: c extern unsigned long int a, b, c; // b and c != 0 MPFR_DECL_INIT( y, DBL_MANT_DIG ); // Fits a double exactly MPFR_DECL_INIT( t, DBL_MANT_DIG*2 ); // Twice the precision I want mpfr_set_ui ( t, a, MPFR_RNDN ); // Exact conversion mpfr_div_ui ( t, t, b, MPFR_RNDN ); // Correctly rounded mpfr_rootn_ui ( y, t, c, MPFR_RNDN ); // N'th root correctly rounded
I'm expecting one of these to hold true:
* Twice the precision for the intermediate is not enough
* Twice the precision for the intermediate is more than needed - I only need N extra bits
* I need to do it differently but it's still possible in a finite time and space
* It's not possible to guarantee correct rounding because of reason 402