Average Error: 30.2 → 23.1
Time: 45.9s
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 -8.670862773875875 \cdot 10^{-30}:\\ \;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \mathbf{elif}\;\frac{1}{n} \le 9.086739455726491 \cdot 10^{-08}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \left(-\frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\right) - \frac{\frac{\frac{1}{2}}{x \cdot n}}{x}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left({\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}\;\frac{1}{n} \le -8.670862773875875 \cdot 10^{-30}:\\
\;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\

\mathbf{elif}\;\frac{1}{n} \le 9.086739455726491 \cdot 10^{-08}:\\
\;\;\;\;\left(\frac{1}{x \cdot n} - \left(-\frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\right) - \frac{\frac{\frac{1}{2}}{x \cdot n}}{x}\\

\mathbf{else}:\\
\;\;\;\;e^{\log \left({\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 r6664041 = x;
        double r6664042 = 1.0;
        double r6664043 = r6664041 + r6664042;
        double r6664044 = n;
        double r6664045 = r6664042 / r6664044;
        double r6664046 = pow(r6664043, r6664045);
        double r6664047 = pow(r6664041, r6664045);
        double r6664048 = r6664046 - r6664047;
        return r6664048;
}

double f(double x, double n) {
        double r6664049 = 1.0;
        double r6664050 = n;
        double r6664051 = r6664049 / r6664050;
        double r6664052 = -8.670862773875875e-30;
        bool r6664053 = r6664051 <= r6664052;
        double r6664054 = x;
        double r6664055 = r6664054 + r6664049;
        double r6664056 = pow(r6664055, r6664051);
        double r6664057 = pow(r6664054, r6664051);
        double r6664058 = r6664056 - r6664057;
        double r6664059 = exp(r6664058);
        double r6664060 = log(r6664059);
        double r6664061 = 9.086739455726491e-08;
        bool r6664062 = r6664051 <= r6664061;
        double r6664063 = r6664054 * r6664050;
        double r6664064 = r6664049 / r6664063;
        double r6664065 = log(r6664054);
        double r6664066 = r6664050 * r6664063;
        double r6664067 = r6664065 / r6664066;
        double r6664068 = -r6664067;
        double r6664069 = r6664064 - r6664068;
        double r6664070 = 0.5;
        double r6664071 = r6664070 / r6664063;
        double r6664072 = r6664071 / r6664054;
        double r6664073 = r6664069 - r6664072;
        double r6664074 = log(r6664058);
        double r6664075 = exp(r6664074);
        double r6664076 = r6664062 ? r6664073 : r6664075;
        double r6664077 = r6664053 ? r6664060 : r6664076;
        return r6664077;
}

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 3 regimes
  2. if (/ 1 n) < -8.670862773875875e-30

    1. Initial program 4.9

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Using strategy rm
    3. Applied add-log-exp5.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-exp5.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-log5.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. Simplified5.1

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

    if -8.670862773875875e-30 < (/ 1 n) < 9.086739455726491e-08

    1. Initial program 45.2

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

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

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

    if 9.086739455726491e-08 < (/ 1 n)

    1. Initial program 25.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \le -8.670862773875875 \cdot 10^{-30}:\\ \;\;\;\;\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \mathbf{elif}\;\frac{1}{n} \le 9.086739455726491 \cdot 10^{-08}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \left(-\frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\right) - \frac{\frac{\frac{1}{2}}{x \cdot n}}{x}\\ \mathbf{else}:\\ \;\;\;\;e^{\log \left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}\\ \end{array}\]

Reproduce

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