Average Error: 32.8 → 12.5
Time: 28.2s
Precision: binary64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
\[\begin{array}{l} t_0 := \frac{\log x}{n}\\ t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\ t_2 := \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {t_1}^{3}, t_1\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_0}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, t_0\right)\right)\right)\\ \mathbf{if}\;n \leq -1.041250944500129 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := {x}^{\left(\frac{1}{n}\right)}\\ t_4 := \frac{t_3}{n \cdot x}\\ \mathbf{if}\;n \leq -24500527.02708143:\\ \;\;\;\;t_4\\ \mathbf{elif}\;n \leq 71783639.15478234:\\ \;\;\;\;\begin{array}{l} t_5 := e^{t_1}\\ \sqrt[3]{{\left(t_5 - e^{t_0}\right)}^{2}} \cdot \sqrt[3]{t_5 - t_3} \end{array}\\ \mathbf{elif}\;n \leq 1.2314344705355872 \cdot 10^{+64}:\\ \;\;\;\;\begin{array}{l} t_6 := n \cdot {x}^{3}\\ \mathsf{fma}\left(0.3333333333333333, \frac{t_3}{t_6}, \mathsf{fma}\left(0.5, \frac{t_3}{\left(n \cdot n\right) \cdot \left(x \cdot x\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_3}{{x}^{3} \cdot {n}^{3}}, t_4\right)\right)\right) - 0.5 \cdot \left(\frac{t_3}{x \cdot \left(n \cdot x\right)} + \frac{t_3}{n \cdot t_6}\right) \end{array}\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array}\\ \end{array} \]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
t_2 := \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {t_1}^{3}, t_1\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {t_0}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, t_0\right)\right)\right)\\
\mathbf{if}\;n \leq -1.041250944500129 \cdot 10^{+126}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := {x}^{\left(\frac{1}{n}\right)}\\
t_4 := \frac{t_3}{n \cdot x}\\
\mathbf{if}\;n \leq -24500527.02708143:\\
\;\;\;\;t_4\\

\mathbf{elif}\;n \leq 71783639.15478234:\\
\;\;\;\;\begin{array}{l}
t_5 := e^{t_1}\\
\sqrt[3]{{\left(t_5 - e^{t_0}\right)}^{2}} \cdot \sqrt[3]{t_5 - t_3}
\end{array}\\

\mathbf{elif}\;n \leq 1.2314344705355872 \cdot 10^{+64}:\\
\;\;\;\;\begin{array}{l}
t_6 := n \cdot {x}^{3}\\
\mathsf{fma}\left(0.3333333333333333, \frac{t_3}{t_6}, \mathsf{fma}\left(0.5, \frac{t_3}{\left(n \cdot n\right) \cdot \left(x \cdot x\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{t_3}{{x}^{3} \cdot {n}^{3}}, t_4\right)\right)\right) - 0.5 \cdot \left(\frac{t_3}{x \cdot \left(n \cdot x\right)} + \frac{t_3}{n \cdot t_6}\right)
\end{array}\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}\\


\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 (/ (log x) n))
        (t_1 (/ (log1p x) n))
        (t_2
         (-
          (fma
           0.5
           (/ (pow (log1p x) 2.0) (* n n))
           (fma
            0.041666666666666664
            (/ (pow (log1p x) 4.0) (pow n 4.0))
            (fma 0.16666666666666666 (pow t_1 3.0) t_1)))
          (fma
           0.16666666666666666
           (pow t_0 3.0)
           (fma
            0.5
            (/ (pow (log x) 2.0) (* n n))
            (fma
             0.041666666666666664
             (/ (pow (log x) 4.0) (pow n 4.0))
             t_0))))))
   (if (<= n -1.041250944500129e+126)
     t_2
     (let* ((t_3 (pow x (/ 1.0 n))) (t_4 (/ t_3 (* n x))))
       (if (<= n -24500527.02708143)
         t_4
         (if (<= n 71783639.15478234)
           (let* ((t_5 (exp t_1)))
             (* (cbrt (pow (- t_5 (exp t_0)) 2.0)) (cbrt (- t_5 t_3))))
           (if (<= n 1.2314344705355872e+64)
             (let* ((t_6 (* n (pow x 3.0))))
               (-
                (fma
                 0.3333333333333333
                 (/ t_3 t_6)
                 (fma
                  0.5
                  (/ t_3 (* (* n n) (* x x)))
                  (fma
                   0.16666666666666666
                   (/ t_3 (* (pow x 3.0) (pow n 3.0)))
                   t_4)))
                (* 0.5 (+ (/ t_3 (* x (* n x))) (/ t_3 (* n t_6))))))
             t_2)))))))
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 = log(x) / n;
	double t_1 = log1p(x) / n;
	double t_2 = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log1p(x), 4.0) / pow(n, 4.0)), fma(0.16666666666666666, pow(t_1, 3.0), t_1))) - fma(0.16666666666666666, pow(t_0, 3.0), fma(0.5, (pow(log(x), 2.0) / (n * n)), fma(0.041666666666666664, (pow(log(x), 4.0) / pow(n, 4.0)), t_0)));
	double tmp;
	if (n <= -1.041250944500129e+126) {
		tmp = t_2;
	} else {
		double t_3 = pow(x, (1.0 / n));
		double t_4 = t_3 / (n * x);
		double tmp_1;
		if (n <= -24500527.02708143) {
			tmp_1 = t_4;
		} else if (n <= 71783639.15478234) {
			double t_5 = exp(t_1);
			tmp_1 = cbrt(pow((t_5 - exp(t_0)), 2.0)) * cbrt(t_5 - t_3);
		} else if (n <= 1.2314344705355872e+64) {
			double t_6 = n * pow(x, 3.0);
			tmp_1 = fma(0.3333333333333333, (t_3 / t_6), fma(0.5, (t_3 / ((n * n) * (x * x))), fma(0.16666666666666666, (t_3 / (pow(x, 3.0) * pow(n, 3.0))), t_4))) - (0.5 * ((t_3 / (x * (n * x))) + (t_3 / (n * t_6))));
		} else {
			tmp_1 = t_2;
		}
		tmp = tmp_1;
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus n

Derivation

  1. Split input into 4 regimes
  2. if n < -1.041250944500129e126 or 1.2314344705355872e64 < n

    1. Initial program 41.2

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}^{3}, \frac{\mathsf{log1p}\left(x\right)}{n}\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\log x}{n}\right)}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, \frac{\log x}{n}\right)\right)\right)} \]

    if -1.041250944500129e126 < n < -24500527.02708143

    1. Initial program 54.0

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

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

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

    if -24500527.02708143 < n < 71783639.1547823399

    1. Initial program 3.2

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Applied add-cube-cbrt_binary643.2

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)} \cdot \sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \]
    4. Simplified2.1

      \[\leadsto \left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right) \cdot \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}} \]
    5. Taylor expanded in n around 0 2.1

      \[\leadsto \color{blue}{{\left({\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\log x}{n}}\right)}^{2}\right)}^{0.3333333333333333}} \cdot \sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \]
    6. Simplified2.1

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

    if 71783639.1547823399 < n < 1.2314344705355872e64

    1. Initial program 54.8

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.041250944500129 \cdot 10^{+126}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}^{3}, \frac{\mathsf{log1p}\left(x\right)}{n}\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\log x}{n}\right)}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, \frac{\log x}{n}\right)\right)\right)\\ \mathbf{elif}\;n \leq -24500527.02708143:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;n \leq 71783639.15478234:\\ \;\;\;\;\sqrt[3]{{\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\log x}{n}}\right)}^{2}} \cdot \sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\\ \mathbf{elif}\;n \leq 1.2314344705355872 \cdot 10^{+64}:\\ \;\;\;\;\mathsf{fma}\left(0.3333333333333333, \frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot {x}^{3}}, \mathsf{fma}\left(0.5, \frac{{x}^{\left(\frac{1}{n}\right)}}{\left(n \cdot n\right) \cdot \left(x \cdot x\right)}, \mathsf{fma}\left(0.16666666666666666, \frac{{x}^{\left(\frac{1}{n}\right)}}{{x}^{3} \cdot {n}^{3}}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\right)\right)\right) - 0.5 \cdot \left(\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot \left(n \cdot x\right)} + \frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot \left(n \cdot {x}^{3}\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{{n}^{4}}, \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}^{3}, \frac{\mathsf{log1p}\left(x\right)}{n}\right)\right)\right) - \mathsf{fma}\left(0.16666666666666666, {\left(\frac{\log x}{n}\right)}^{3}, \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \mathsf{fma}\left(0.041666666666666664, \frac{{\log x}^{4}}{{n}^{4}}, \frac{\log x}{n}\right)\right)\right)\\ \end{array} \]

Reproduce

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