Average Error: 28.7 → 22.3
Time: 26.0s
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):\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \frac{0.5}{{x}^{2} \cdot n}\right) - 1 \cdot \frac{-\log x}{x \cdot {n}^{2}}\\ \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):\\
\;\;\;\;\left(\frac{1}{x \cdot n} - \frac{0.5}{{x}^{2} \cdot n}\right) - 1 \cdot \frac{-\log x}{x \cdot {n}^{2}}\\

\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 r78705 = x;
        double r78706 = 1.0;
        double r78707 = r78705 + r78706;
        double r78708 = n;
        double r78709 = r78706 / r78708;
        double r78710 = pow(r78707, r78709);
        double r78711 = pow(r78705, r78709);
        double r78712 = r78710 - r78711;
        return r78712;
}

double f(double x, double n) {
        double r78713 = n;
        double r78714 = -73053226.23717305;
        bool r78715 = r78713 <= r78714;
        double r78716 = 2.8287508845642576e+19;
        bool r78717 = r78713 <= r78716;
        double r78718 = !r78717;
        bool r78719 = r78715 || r78718;
        double r78720 = 1.0;
        double r78721 = x;
        double r78722 = r78721 * r78713;
        double r78723 = r78720 / r78722;
        double r78724 = 0.5;
        double r78725 = 2.0;
        double r78726 = pow(r78721, r78725);
        double r78727 = r78726 * r78713;
        double r78728 = r78724 / r78727;
        double r78729 = r78723 - r78728;
        double r78730 = log(r78721);
        double r78731 = -r78730;
        double r78732 = pow(r78713, r78725);
        double r78733 = r78721 * r78732;
        double r78734 = r78731 / r78733;
        double r78735 = r78720 * r78734;
        double r78736 = r78729 - r78735;
        double r78737 = r78721 + r78720;
        double r78738 = r78720 / r78713;
        double r78739 = pow(r78737, r78738);
        double r78740 = pow(r78721, r78738);
        double r78741 = r78739 - r78740;
        double r78742 = exp(r78741);
        double r78743 = log(r78742);
        double r78744 = r78719 ? r78736 : r78743;
        return r78744;
}

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 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}{\left(\frac{1}{x \cdot n} - \frac{0.5}{{x}^{2} \cdot n}\right) - 1 \cdot \frac{-\log x}{x \cdot {n}^{2}}}\]

    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):\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \frac{0.5}{{x}^{2} \cdot n}\right) - 1 \cdot \frac{-\log x}{x \cdot {n}^{2}}\\ \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 
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))