Average Error: 30.3 → 22.7
Time: 11.4s
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(-\mathsf{fma}\left(0.5, \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left({x}^{2} \cdot n\right)\right)}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\right)\\ \mathbf{elif}\;n \le 7221255.7902708035:\\ \;\;\;\;{\left({\left(x + 1\right)}^{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt[3]{n} \cdot \sqrt[3]{n}}\right)}\right)}^{\left(\frac{\sqrt[3]{1}}{\sqrt[3]{n}}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, 1 \cdot \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}\;n \le -27760508.405810945:\\
\;\;\;\;\frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left({x}^{2} \cdot n\right)\right)}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, 1 \cdot \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 r57657 = x;
        double r57658 = 1.0;
        double r57659 = r57657 + r57658;
        double r57660 = n;
        double r57661 = r57658 / r57660;
        double r57662 = pow(r57659, r57661);
        double r57663 = pow(r57657, r57661);
        double r57664 = r57662 - r57663;
        return r57664;
}

double f(double x, double n) {
        double r57665 = n;
        double r57666 = -27760508.405810945;
        bool r57667 = r57665 <= r57666;
        double r57668 = 1.0;
        double r57669 = r57668 / r57665;
        double r57670 = x;
        double r57671 = r57669 / r57670;
        double r57672 = 0.5;
        double r57673 = 1.0;
        double r57674 = 2.0;
        double r57675 = pow(r57670, r57674);
        double r57676 = r57675 * r57665;
        double r57677 = expm1(r57676);
        double r57678 = log1p(r57677);
        double r57679 = r57673 / r57678;
        double r57680 = r57673 / r57670;
        double r57681 = log(r57680);
        double r57682 = pow(r57665, r57674);
        double r57683 = r57670 * r57682;
        double r57684 = r57681 / r57683;
        double r57685 = r57668 * r57684;
        double r57686 = fma(r57672, r57679, r57685);
        double r57687 = -r57686;
        double r57688 = r57671 + r57687;
        double r57689 = 7221255.7902708035;
        bool r57690 = r57665 <= r57689;
        double r57691 = r57670 + r57668;
        double r57692 = cbrt(r57668);
        double r57693 = r57692 * r57692;
        double r57694 = cbrt(r57665);
        double r57695 = r57694 * r57694;
        double r57696 = r57693 / r57695;
        double r57697 = pow(r57691, r57696);
        double r57698 = r57692 / r57694;
        double r57699 = pow(r57697, r57698);
        double r57700 = pow(r57670, r57669);
        double r57701 = r57699 - r57700;
        double r57702 = r57673 / r57676;
        double r57703 = r57673 * r57702;
        double r57704 = fma(r57672, r57703, r57685);
        double r57705 = -r57704;
        double r57706 = r57671 + r57705;
        double r57707 = r57690 ? r57701 : r57706;
        double r57708 = r57667 ? r57688 : r57707;
        return r57708;
}

Error

Bits error versus x

Bits error versus n

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.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)}\]
    4. Using strategy rm
    5. Applied fma-udef32.6

      \[\leadsto \color{blue}{1 \cdot \frac{1}{x \cdot n} + \left(-\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)}\]
    6. Simplified32.1

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} + \left(-\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)\]
    7. Using strategy rm
    8. Applied log1p-expm1-u32.0

      \[\leadsto \frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, \frac{1}{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left({x}^{2} \cdot n\right)\right)}}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\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 add-cube-cbrt9.1

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{\color{blue}{\left(\sqrt[3]{n} \cdot \sqrt[3]{n}\right) \cdot \sqrt[3]{n}}}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied add-cube-cbrt9.1

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\left(\sqrt[3]{n} \cdot \sqrt[3]{n}\right) \cdot \sqrt[3]{n}}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    5. Applied times-frac9.1

      \[\leadsto {\left(x + 1\right)}^{\color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt[3]{n} \cdot \sqrt[3]{n}} \cdot \frac{\sqrt[3]{1}}{\sqrt[3]{n}}\right)}} - {x}^{\left(\frac{1}{n}\right)}\]
    6. Applied pow-unpow9.2

      \[\leadsto \color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt[3]{n} \cdot \sqrt[3]{n}}\right)}\right)}^{\left(\frac{\sqrt[3]{1}}{\sqrt[3]{n}}\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.7

      \[\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)}\]
    4. Using strategy rm
    5. Applied fma-udef32.7

      \[\leadsto \color{blue}{1 \cdot \frac{1}{x \cdot n} + \left(-\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)}\]
    6. Simplified32.0

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} + \left(-\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)\]
    7. Using strategy rm
    8. Applied *-un-lft-identity32.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -27760508.405810945:\\ \;\;\;\;\frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, \frac{1}{\mathsf{log1p}\left(\mathsf{expm1}\left({x}^{2} \cdot n\right)\right)}, 1 \cdot \frac{\log \left(\frac{1}{x}\right)}{x \cdot {n}^{2}}\right)\right)\\ \mathbf{elif}\;n \le 7221255.7902708035:\\ \;\;\;\;{\left({\left(x + 1\right)}^{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\sqrt[3]{n} \cdot \sqrt[3]{n}}\right)}\right)}^{\left(\frac{\sqrt[3]{1}}{\sqrt[3]{n}}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} + \left(-\mathsf{fma}\left(0.5, 1 \cdot \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 2020034 +o rules:numerics
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))