Average Error: 29.4 → 22.6
Time: 11.1s
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 -2.79615408801549922 \cdot 10^{-19} \lor \neg \left(\frac{1}{n} \le 2.0348385096999655 \cdot 10^{-19}\right):\\ \;\;\;\;e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \left(\log \left(e^{\frac{0.5}{\log \left(e^{{x}^{2} \cdot n}\right)}}\right) - \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 -2.79615408801549922 \cdot 10^{-19} \lor \neg \left(\frac{1}{n} \le 2.0348385096999655 \cdot 10^{-19}\right):\\
\;\;\;\;e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}\\

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

\end{array}
double f(double x, double n) {
        double r71602 = x;
        double r71603 = 1.0;
        double r71604 = r71602 + r71603;
        double r71605 = n;
        double r71606 = r71603 / r71605;
        double r71607 = pow(r71604, r71606);
        double r71608 = pow(r71602, r71606);
        double r71609 = r71607 - r71608;
        return r71609;
}

double f(double x, double n) {
        double r71610 = 1.0;
        double r71611 = n;
        double r71612 = r71610 / r71611;
        double r71613 = -2.796154088015499e-19;
        bool r71614 = r71612 <= r71613;
        double r71615 = 2.0348385096999655e-19;
        bool r71616 = r71612 <= r71615;
        double r71617 = !r71616;
        bool r71618 = r71614 || r71617;
        double r71619 = x;
        double r71620 = r71619 + r71610;
        double r71621 = pow(r71620, r71612);
        double r71622 = pow(r71619, r71612);
        double r71623 = r71621 - r71622;
        double r71624 = log(r71623);
        double r71625 = exp(r71624);
        double r71626 = r71612 / r71619;
        double r71627 = 0.5;
        double r71628 = 2.0;
        double r71629 = pow(r71619, r71628);
        double r71630 = r71629 * r71611;
        double r71631 = exp(r71630);
        double r71632 = log(r71631);
        double r71633 = r71627 / r71632;
        double r71634 = exp(r71633);
        double r71635 = log(r71634);
        double r71636 = log(r71619);
        double r71637 = r71636 * r71610;
        double r71638 = pow(r71611, r71628);
        double r71639 = r71619 * r71638;
        double r71640 = r71637 / r71639;
        double r71641 = r71635 - r71640;
        double r71642 = r71626 - r71641;
        double r71643 = r71618 ? r71625 : r71642;
        return r71643;
}

Error

Bits error versus x

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if (/ 1.0 n) < -2.796154088015499e-19 or 2.0348385096999655e-19 < (/ 1.0 n)

    1. Initial program 10.3

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

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

    if -2.796154088015499e-19 < (/ 1.0 n) < 2.0348385096999655e-19

    1. Initial program 44.9

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

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

      \[\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)}\]
    4. Using strategy rm
    5. Applied add-log-exp31.8

      \[\leadsto \frac{\frac{1}{n}}{x} - \left(\color{blue}{\log \left(e^{\frac{\frac{0.5}{n}}{{x}^{2}}}\right)} - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\]
    6. Simplified31.8

      \[\leadsto \frac{\frac{1}{n}}{x} - \left(\log \color{blue}{\left(e^{\frac{0.5}{{x}^{2} \cdot n}}\right)} - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\]
    7. Using strategy rm
    8. Applied add-log-exp31.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \le -2.79615408801549922 \cdot 10^{-19} \lor \neg \left(\frac{1}{n} \le 2.0348385096999655 \cdot 10^{-19}\right):\\ \;\;\;\;e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \left(\log \left(e^{\frac{0.5}{\log \left(e^{{x}^{2} \cdot n}\right)}}\right) - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\\ \end{array}\]

Reproduce

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