Average Error: 32.8 → 17.8
Time: 13.5s
Precision: binary64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
\[\begin{array}{l} t_0 := \sqrt[3]{\left(x + n\right) - n}\\ t_1 := e^{-1 \cdot \frac{-\log x}{n}}\\ \mathbf{if}\;x \leq -2.9019362550020532 \cdot 10^{+193}:\\ \;\;\;\;\frac{\frac{x}{\sqrt[3]{n \cdot n}}}{\sqrt[3]{n}}\\ \mathbf{elif}\;x \leq 1.846802285931436 \cdot 10^{-308}:\\ \;\;\;\;\frac{\mathsf{fma}\left({t_0}^{2}, t_0, 0\right)}{n}\\ \mathbf{elif}\;x \leq 1.2179570994719419 \cdot 10^{-236}:\\ \;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\ \mathbf{elif}\;x \leq 4.616680033797104 \cdot 10^{-189}:\\ \;\;\;\;{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}\\ \mathbf{elif}\;x \leq 808.4781327219058:\\ \;\;\;\;-1 \cdot \frac{\log x - \mathsf{log1p}\left(x\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.4583333333333333, \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{4}}, \mathsf{fma}\left(0.3333333333333333, \frac{t_1}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.041666666666666664, \frac{t_1}{{x}^{4} \cdot {n}^{4}}, \mathsf{fma}\left(0.5, \frac{t_1}{\left(x \cdot x\right) \cdot \left(n \cdot n\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_1}{{x}^{3} \cdot {n}^{3}}, \frac{t_1}{x \cdot n}\right)\right)\right)\right)\right) - \mathsf{fma}\left(0.25, \frac{t_1}{n \cdot {x}^{4}} + \frac{t_1}{{n}^{3} \cdot {x}^{4}}, 0.5 \cdot \left(\frac{t_1}{n \cdot \left(x \cdot x\right)} + \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{3}}\right)\right)\\ \end{array} \]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := \sqrt[3]{\left(x + n\right) - n}\\
t_1 := e^{-1 \cdot \frac{-\log x}{n}}\\
\mathbf{if}\;x \leq -2.9019362550020532 \cdot 10^{+193}:\\
\;\;\;\;\frac{\frac{x}{\sqrt[3]{n \cdot n}}}{\sqrt[3]{n}}\\

\mathbf{elif}\;x \leq 1.846802285931436 \cdot 10^{-308}:\\
\;\;\;\;\frac{\mathsf{fma}\left({t_0}^{2}, t_0, 0\right)}{n}\\

\mathbf{elif}\;x \leq 1.2179570994719419 \cdot 10^{-236}:\\
\;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\

\mathbf{elif}\;x \leq 4.616680033797104 \cdot 10^{-189}:\\
\;\;\;\;{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}\\

\mathbf{elif}\;x \leq 808.4781327219058:\\
\;\;\;\;-1 \cdot \frac{\log x - \mathsf{log1p}\left(x\right)}{n}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(0.4583333333333333, \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{4}}, \mathsf{fma}\left(0.3333333333333333, \frac{t_1}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.041666666666666664, \frac{t_1}{{x}^{4} \cdot {n}^{4}}, \mathsf{fma}\left(0.5, \frac{t_1}{\left(x \cdot x\right) \cdot \left(n \cdot n\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_1}{{x}^{3} \cdot {n}^{3}}, \frac{t_1}{x \cdot n}\right)\right)\right)\right)\right) - \mathsf{fma}\left(0.25, \frac{t_1}{n \cdot {x}^{4}} + \frac{t_1}{{n}^{3} \cdot {x}^{4}}, 0.5 \cdot \left(\frac{t_1}{n \cdot \left(x \cdot x\right)} + \frac{t_1}{\left(n \cdot n\right) \cdot {x}^{3}}\right)\right)\\


\end{array}
(FPCore (x n)
 :precision binary64
 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (cbrt (- (+ x n) n))) (t_1 (exp (* -1.0 (/ (- (log x)) n)))))
   (if (<= x -2.9019362550020532e+193)
     (/ (/ x (cbrt (* n n))) (cbrt n))
     (if (<= x 1.846802285931436e-308)
       (/ (fma (pow t_0 2.0) t_0 0.0) n)
       (if (<= x 1.2179570994719419e-236)
         (/ (- (log (+ 1.0 x)) (log x)) n)
         (if (<= x 4.616680033797104e-189)
           (pow (sqrt (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))) 2.0)
           (if (<= x 808.4781327219058)
             (* -1.0 (/ (- (log x) (log1p x)) n))
             (-
              (fma
               0.4583333333333333
               (/ t_1 (* (* n n) (pow x 4.0)))
               (fma
                0.3333333333333333
                (/ t_1 (* n (pow x 3.0)))
                (fma
                 0.041666666666666664
                 (/ t_1 (* (pow x 4.0) (pow n 4.0)))
                 (fma
                  0.5
                  (/ t_1 (* (* x x) (* n n)))
                  (fma
                   0.16666666666666666
                   (/ t_1 (* (pow x 3.0) (pow n 3.0)))
                   (/ t_1 (* x n)))))))
              (fma
               0.25
               (+
                (/ t_1 (* n (pow x 4.0)))
                (/ t_1 (* (pow n 3.0) (pow x 4.0))))
               (*
                0.5
                (+
                 (/ t_1 (* n (* x x)))
                 (/ t_1 (* (* n n) (pow x 3.0))))))))))))))
double code(double x, double n) {
	return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
double code(double x, double n) {
	double t_0 = cbrt(((x + n) - n));
	double t_1 = exp((-1.0 * (-log(x) / n)));
	double tmp;
	if (x <= -2.9019362550020532e+193) {
		tmp = (x / cbrt((n * n))) / cbrt(n);
	} else if (x <= 1.846802285931436e-308) {
		tmp = fma(pow(t_0, 2.0), t_0, 0.0) / n;
	} else if (x <= 1.2179570994719419e-236) {
		tmp = (log((1.0 + x)) - log(x)) / n;
	} else if (x <= 4.616680033797104e-189) {
		tmp = pow(sqrt((exp((log1p(x) / n)) - pow(x, (1.0 / n)))), 2.0);
	} else if (x <= 808.4781327219058) {
		tmp = -1.0 * ((log(x) - log1p(x)) / n);
	} else {
		tmp = fma(0.4583333333333333, (t_1 / ((n * n) * pow(x, 4.0))), fma(0.3333333333333333, (t_1 / (n * pow(x, 3.0))), fma(0.041666666666666664, (t_1 / (pow(x, 4.0) * pow(n, 4.0))), fma(0.5, (t_1 / ((x * x) * (n * n))), fma(0.16666666666666666, (t_1 / (pow(x, 3.0) * pow(n, 3.0))), (t_1 / (x * n))))))) - fma(0.25, ((t_1 / (n * pow(x, 4.0))) + (t_1 / (pow(n, 3.0) * pow(x, 4.0)))), (0.5 * ((t_1 / (n * (x * x))) + (t_1 / ((n * n) * pow(x, 3.0))))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus n

Derivation

  1. Split input into 6 regimes
  2. if x < -2.9019362550020532e193

    1. Initial program 32.8

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{1} \]
    3. Taylor expanded in x around 0 56.8

      \[\leadsto \color{blue}{\left(\frac{x}{n} + 1\right)} - 1 \]
    4. Simplified56.8

      \[\leadsto \color{blue}{\left(1 + \frac{x}{n}\right)} - 1 \]
    5. Applied egg-rr53.0

      \[\leadsto \color{blue}{\frac{\frac{x}{\sqrt[3]{n \cdot n}}}{\sqrt[3]{n}}} \]

    if -2.9019362550020532e193 < x < 1.846802285931436e-308

    1. Initial program 61.7

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{1} \]
    3. Taylor expanded in x around 0 61.7

      \[\leadsto \color{blue}{\left(\frac{x}{n} + 1\right)} - 1 \]
    4. Simplified61.7

      \[\leadsto \color{blue}{\left(1 + \frac{x}{n}\right)} - 1 \]
    5. Applied egg-rr61.7

      \[\leadsto \color{blue}{\frac{\left(x + n\right) - n}{n}} \]
    6. Applied egg-rr61.7

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left({\left(\sqrt[3]{\left(x + n\right) - n}\right)}^{2}, \sqrt[3]{\left(x + n\right) - n}, 0\right)}}{n} \]

    if 1.846802285931436e-308 < x < 1.21795709947194186e-236

    1. Initial program 40.8

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

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

    if 1.21795709947194186e-236 < x < 4.6166800337971042e-189

    1. Initial program 43.2

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Applied egg-rr43.2

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]

    if 4.6166800337971042e-189 < x < 808.478132721905808

    1. Initial program 51.1

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x - \log \left(1 + x\right)}{n}} \]
    3. Simplified9.7

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

    if 808.478132721905808 < x

    1. Initial program 20.7

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

      \[\leadsto \color{blue}{\left(0.4583333333333333 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{2} \cdot {x}^{4}} + \left(0.3333333333333333 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot {x}^{3}} + \left(0.041666666666666664 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{4} \cdot {x}^{4}} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x} + \left(0.5 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{2} \cdot {x}^{2}} + 0.16666666666666666 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{3} \cdot {x}^{3}}\right)\right)\right)\right)\right) - \left(0.5 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot {x}^{2}} + \left(0.5 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{2} \cdot {x}^{3}} + \left(0.25 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot {x}^{4}} + 0.25 \cdot \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{n}^{3} \cdot {x}^{4}}\right)\right)\right)} \]
    3. Simplified17.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.4583333333333333, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(n \cdot n\right) \cdot {x}^{4}}, \mathsf{fma}\left(0.3333333333333333, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.041666666666666664, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{x}^{4} \cdot {n}^{4}}, \mathsf{fma}\left(0.5, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(x \cdot x\right) \cdot \left(n \cdot n\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{x}^{3} \cdot {n}^{3}}, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{x \cdot n}\right)\right)\right)\right)\right) - \mathsf{fma}\left(0.25, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot {x}^{4}} + \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{n}^{3} \cdot {x}^{4}}, 0.5 \cdot \left(\frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot \left(x \cdot x\right)} + \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(n \cdot n\right) \cdot {x}^{3}}\right)\right)} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification17.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9019362550020532 \cdot 10^{+193}:\\ \;\;\;\;\frac{\frac{x}{\sqrt[3]{n \cdot n}}}{\sqrt[3]{n}}\\ \mathbf{elif}\;x \leq 1.846802285931436 \cdot 10^{-308}:\\ \;\;\;\;\frac{\mathsf{fma}\left({\left(\sqrt[3]{\left(x + n\right) - n}\right)}^{2}, \sqrt[3]{\left(x + n\right) - n}, 0\right)}{n}\\ \mathbf{elif}\;x \leq 1.2179570994719419 \cdot 10^{-236}:\\ \;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\ \mathbf{elif}\;x \leq 4.616680033797104 \cdot 10^{-189}:\\ \;\;\;\;{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}\\ \mathbf{elif}\;x \leq 808.4781327219058:\\ \;\;\;\;-1 \cdot \frac{\log x - \mathsf{log1p}\left(x\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.4583333333333333, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(n \cdot n\right) \cdot {x}^{4}}, \mathsf{fma}\left(0.3333333333333333, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.041666666666666664, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{x}^{4} \cdot {n}^{4}}, \mathsf{fma}\left(0.5, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(x \cdot x\right) \cdot \left(n \cdot n\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{x}^{3} \cdot {n}^{3}}, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{x \cdot n}\right)\right)\right)\right)\right) - \mathsf{fma}\left(0.25, \frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot {x}^{4}} + \frac{e^{-1 \cdot \frac{-\log x}{n}}}{{n}^{3} \cdot {x}^{4}}, 0.5 \cdot \left(\frac{e^{-1 \cdot \frac{-\log x}{n}}}{n \cdot \left(x \cdot x\right)} + \frac{e^{-1 \cdot \frac{-\log x}{n}}}{\left(n \cdot n\right) \cdot {x}^{3}}\right)\right)\\ \end{array} \]

Reproduce

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