Average Error: 28.7 → 22.3
Time: 32.5s
Precision: 64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;n \le -73053226.2371730506420135498046875 \lor \neg \left(n \le 28287508845642575872\right):\\ \;\;\;\;\frac{1}{x \cdot n} - \mathsf{fma}\left(1, \frac{-\log x}{x \cdot {n}^{2}}, \frac{0.5}{{x}^{2} \cdot n}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \end{array}\]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;n \le -73053226.2371730506420135498046875 \lor \neg \left(n \le 28287508845642575872\right):\\
\;\;\;\;\frac{1}{x \cdot n} - \mathsf{fma}\left(1, \frac{-\log x}{x \cdot {n}^{2}}, \frac{0.5}{{x}^{2} \cdot n}\right)\\

\mathbf{else}:\\
\;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\

\end{array}
double f(double x, double n) {
        double r80558 = x;
        double r80559 = 1.0;
        double r80560 = r80558 + r80559;
        double r80561 = n;
        double r80562 = r80559 / r80561;
        double r80563 = pow(r80560, r80562);
        double r80564 = pow(r80558, r80562);
        double r80565 = r80563 - r80564;
        return r80565;
}

double f(double x, double n) {
        double r80566 = n;
        double r80567 = -73053226.23717305;
        bool r80568 = r80566 <= r80567;
        double r80569 = 2.8287508845642576e+19;
        bool r80570 = r80566 <= r80569;
        double r80571 = !r80570;
        bool r80572 = r80568 || r80571;
        double r80573 = 1.0;
        double r80574 = x;
        double r80575 = r80574 * r80566;
        double r80576 = r80573 / r80575;
        double r80577 = log(r80574);
        double r80578 = -r80577;
        double r80579 = 2.0;
        double r80580 = pow(r80566, r80579);
        double r80581 = r80574 * r80580;
        double r80582 = r80578 / r80581;
        double r80583 = 0.5;
        double r80584 = pow(r80574, r80579);
        double r80585 = r80584 * r80566;
        double r80586 = r80583 / r80585;
        double r80587 = fma(r80573, r80582, r80586);
        double r80588 = r80576 - r80587;
        double r80589 = r80574 + r80573;
        double r80590 = r80573 / r80566;
        double r80591 = pow(r80589, r80590);
        double r80592 = pow(r80574, r80590);
        double r80593 = r80591 - r80592;
        double r80594 = exp(r80593);
        double r80595 = log(r80594);
        double r80596 = r80572 ? r80588 : r80595;
        return r80596;
}

Error

Bits error versus x

Bits error versus n

Derivation

  1. Split input into 2 regimes
  2. if n < -73053226.23717305 or 2.8287508845642576e+19 < n

    1. Initial program 44.7

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around inf 33.0

      \[\leadsto \color{blue}{1 \cdot \frac{1}{x \cdot n} - \left(0.5 \cdot \frac{1}{{x}^{2} \cdot n} + 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)}\]
    3. Simplified33.0

      \[\leadsto \color{blue}{\frac{1}{x \cdot n} - \mathsf{fma}\left(1, \frac{-\log x}{x \cdot {n}^{2}}, \frac{0.5}{{x}^{2} \cdot n}\right)}\]

    if -73053226.23717305 < n < 2.8287508845642576e+19

    1. Initial program 8.9

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Using strategy rm
    3. Applied add-log-exp9.2

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{\log \left(e^{{x}^{\left(\frac{1}{n}\right)}}\right)}\]
    4. Applied add-log-exp9.1

      \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}\right)} - \log \left(e^{{x}^{\left(\frac{1}{n}\right)}}\right)\]
    5. Applied diff-log9.1

      \[\leadsto \color{blue}{\log \left(\frac{e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}}{e^{{x}^{\left(\frac{1}{n}\right)}}}\right)}\]
    6. Simplified9.1

      \[\leadsto \log \color{blue}{\left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification22.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -73053226.2371730506420135498046875 \lor \neg \left(n \le 28287508845642575872\right):\\ \;\;\;\;\frac{1}{x \cdot n} - \mathsf{fma}\left(1, \frac{-\log x}{x \cdot {n}^{2}}, \frac{0.5}{{x}^{2} \cdot n}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019208 +o rules:numerics
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))