Average Error: 29.2 → 22.1
Time: 12.5s
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 -4.591364776215535476182165581533253078392 \cdot 10^{-22} \lor \neg \left(\frac{1}{n} \le 7.083664182173738223528513410730390458454 \cdot 10^{-15}\right):\\ \;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(1, \frac{1}{x \cdot n}, -\mathsf{fma}\left(0.5, \frac{1}{{x}^{2} \cdot n}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\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 -4.591364776215535476182165581533253078392 \cdot 10^{-22} \lor \neg \left(\frac{1}{n} \le 7.083664182173738223528513410730390458454 \cdot 10^{-15}\right):\\
\;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\

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

\end{array}
double f(double x, double n) {
        double r72362 = x;
        double r72363 = 1.0;
        double r72364 = r72362 + r72363;
        double r72365 = n;
        double r72366 = r72363 / r72365;
        double r72367 = pow(r72364, r72366);
        double r72368 = pow(r72362, r72366);
        double r72369 = r72367 - r72368;
        return r72369;
}

double f(double x, double n) {
        double r72370 = 1.0;
        double r72371 = n;
        double r72372 = r72370 / r72371;
        double r72373 = -4.5913647762155355e-22;
        bool r72374 = r72372 <= r72373;
        double r72375 = 7.083664182173738e-15;
        bool r72376 = r72372 <= r72375;
        double r72377 = !r72376;
        bool r72378 = r72374 || r72377;
        double r72379 = x;
        double r72380 = r72379 + r72370;
        double r72381 = pow(r72380, r72372);
        double r72382 = pow(r72379, r72372);
        double r72383 = r72381 - r72382;
        double r72384 = exp(r72383);
        double r72385 = log(r72384);
        double r72386 = 1.0;
        double r72387 = r72379 * r72371;
        double r72388 = r72386 / r72387;
        double r72389 = 0.5;
        double r72390 = 2.0;
        double r72391 = pow(r72379, r72390);
        double r72392 = r72391 * r72371;
        double r72393 = r72386 / r72392;
        double r72394 = r72386 / r72379;
        double r72395 = log(r72394);
        double r72396 = pow(r72371, r72390);
        double r72397 = r72379 * r72396;
        double r72398 = r72395 / r72397;
        double r72399 = r72370 * r72398;
        double r72400 = fma(r72389, r72393, r72399);
        double r72401 = -r72400;
        double r72402 = fma(r72370, r72388, r72401);
        double r72403 = r72378 ? r72385 : r72402;
        return r72403;
}

Error

Bits error versus x

Bits error versus n

Derivation

  1. Split input into 2 regimes
  2. if (/ 1.0 n) < -4.5913647762155355e-22 or 7.083664182173738e-15 < (/ 1.0 n)

    1. Initial program 10.2

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

      \[\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-exp10.3

      \[\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-log10.3

      \[\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. Simplified10.3

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

    if -4.5913647762155355e-22 < (/ 1.0 n) < 7.083664182173738e-15

    1. Initial program 44.5

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

      \[\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. Simplified31.6

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

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

Reproduce

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