Average Error: 28.9 → 22.2
Time: 19.2s
Precision: 64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{n} \le -233664840384.73187 \lor \neg \left(\frac{1}{n} \le 9.51106135594814073 \cdot 10^{-15}\right):\\ \;\;\;\;\mathsf{fma}\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, -{x}^{\left(\frac{1}{n}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \left(\frac{\frac{0.5}{n}}{{x}^{2}} - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\\ \end{array}\]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \le -233664840384.73187 \lor \neg \left(\frac{1}{n} \le 9.51106135594814073 \cdot 10^{-15}\right):\\
\;\;\;\;\mathsf{fma}\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, -{x}^{\left(\frac{1}{n}\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \left(\frac{\frac{0.5}{n}}{{x}^{2}} - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\\

\end{array}
double f(double x, double n) {
        double r97403 = x;
        double r97404 = 1.0;
        double r97405 = r97403 + r97404;
        double r97406 = n;
        double r97407 = r97404 / r97406;
        double r97408 = pow(r97405, r97407);
        double r97409 = pow(r97403, r97407);
        double r97410 = r97408 - r97409;
        return r97410;
}

double f(double x, double n) {
        double r97411 = 1.0;
        double r97412 = n;
        double r97413 = r97411 / r97412;
        double r97414 = -233664840384.73187;
        bool r97415 = r97413 <= r97414;
        double r97416 = 9.51106135594814e-15;
        bool r97417 = r97413 <= r97416;
        double r97418 = !r97417;
        bool r97419 = r97415 || r97418;
        double r97420 = x;
        double r97421 = r97420 + r97411;
        double r97422 = pow(r97421, r97413);
        double r97423 = sqrt(r97422);
        double r97424 = pow(r97420, r97413);
        double r97425 = -r97424;
        double r97426 = fma(r97423, r97423, r97425);
        double r97427 = r97413 / r97420;
        double r97428 = 0.5;
        double r97429 = r97428 / r97412;
        double r97430 = 2.0;
        double r97431 = pow(r97420, r97430);
        double r97432 = r97429 / r97431;
        double r97433 = log(r97420);
        double r97434 = r97433 * r97411;
        double r97435 = pow(r97412, r97430);
        double r97436 = r97420 * r97435;
        double r97437 = r97434 / r97436;
        double r97438 = r97432 - r97437;
        double r97439 = r97427 - r97438;
        double r97440 = r97419 ? r97426 : r97439;
        return r97440;
}

Error

Bits error versus x

Bits error versus n

Derivation

  1. Split input into 2 regimes
  2. if (/ 1.0 n) < -233664840384.73187 or 9.51106135594814e-15 < (/ 1.0 n)

    1. Initial program 8.3

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

      \[\leadsto \color{blue}{\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \cdot \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied fma-neg8.3

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, -{x}^{\left(\frac{1}{n}\right)}\right)}\]

    if -233664840384.73187 < (/ 1.0 n) < 9.51106135594814e-15

    1. Initial program 43.9

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

      \[\leadsto \color{blue}{\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \cdot \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied fma-neg44.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, \sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}, -{x}^{\left(\frac{1}{n}\right)}\right)}\]
    5. Taylor expanded around inf 32.9

      \[\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)}\]
    6. Simplified32.3

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

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

Reproduce

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