Average Error: 30.3 → 22.9
Time: 10.6s
Precision: 64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;n \le -27760508.405810945:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \left(\log \left(e^{\frac{0.5}{{x}^{2} \cdot n}}\right) - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\\ \mathbf{elif}\;n \le 7221255.7902708035:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{\frac{1}{n}}{2}\right)} \cdot {\left(x + 1\right)}^{\left(\frac{\frac{1}{n}}{2}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(1 \cdot \frac{1}{x \cdot n} + 1 \cdot \frac{\log x}{x \cdot {n}^{2}}\right) - 0.5 \cdot \frac{1}{{x}^{2} \cdot n}\\ \end{array}\]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;n \le -27760508.405810945:\\
\;\;\;\;\frac{\frac{1}{n}}{x} - \left(\log \left(e^{\frac{0.5}{{x}^{2} \cdot n}}\right) - \frac{\log x \cdot 1}{x \cdot {n}^{2}}\right)\\

\mathbf{elif}\;n \le 7221255.7902708035:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{\frac{1}{n}}{2}\right)} \cdot {\left(x + 1\right)}^{\left(\frac{\frac{1}{n}}{2}\right)} - {x}^{\left(\frac{1}{n}\right)}\\

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

\end{array}
double f(double x, double n) {
        double r65544 = x;
        double r65545 = 1.0;
        double r65546 = r65544 + r65545;
        double r65547 = n;
        double r65548 = r65545 / r65547;
        double r65549 = pow(r65546, r65548);
        double r65550 = pow(r65544, r65548);
        double r65551 = r65549 - r65550;
        return r65551;
}

double f(double x, double n) {
        double r65552 = n;
        double r65553 = -27760508.405810945;
        bool r65554 = r65552 <= r65553;
        double r65555 = 1.0;
        double r65556 = r65555 / r65552;
        double r65557 = x;
        double r65558 = r65556 / r65557;
        double r65559 = 0.5;
        double r65560 = 2.0;
        double r65561 = pow(r65557, r65560);
        double r65562 = r65561 * r65552;
        double r65563 = r65559 / r65562;
        double r65564 = exp(r65563);
        double r65565 = log(r65564);
        double r65566 = log(r65557);
        double r65567 = r65566 * r65555;
        double r65568 = pow(r65552, r65560);
        double r65569 = r65557 * r65568;
        double r65570 = r65567 / r65569;
        double r65571 = r65565 - r65570;
        double r65572 = r65558 - r65571;
        double r65573 = 7221255.7902708035;
        bool r65574 = r65552 <= r65573;
        double r65575 = r65557 + r65555;
        double r65576 = r65556 / r65560;
        double r65577 = pow(r65575, r65576);
        double r65578 = r65577 * r65577;
        double r65579 = pow(r65557, r65556);
        double r65580 = r65578 - r65579;
        double r65581 = 1.0;
        double r65582 = r65557 * r65552;
        double r65583 = r65581 / r65582;
        double r65584 = r65555 * r65583;
        double r65585 = r65566 / r65569;
        double r65586 = r65555 * r65585;
        double r65587 = r65584 + r65586;
        double r65588 = r65581 / r65562;
        double r65589 = r65559 * r65588;
        double r65590 = r65587 - r65589;
        double r65591 = r65574 ? r65580 : r65590;
        double r65592 = r65554 ? r65572 : r65591;
        return r65592;
}

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 n < -27760508.405810945

    1. Initial program 45.3

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around inf 32.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. Simplified32.1

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

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

      \[\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)\]

    if -27760508.405810945 < n < 7221255.7902708035

    1. Initial program 9.1

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

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

    if 7221255.7902708035 < n

    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 32.7

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

      \[\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. Taylor expanded around 0 32.7

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

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

Reproduce

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