Average Error: 29.3 → 0.5
Time: 7.9s
Precision: binary64
Cost: 52356
\[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := \sqrt[3]{x} + t_0\\ \mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\ \end{array} \]
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (+ (cbrt x) t_0)))
   (if (<= (- t_0 (cbrt x)) 0.0)
     (/ 1.0 (fma (cbrt x) t_1 (pow (cbrt x) 2.0)))
     (/ 1.0 (fma (cbrt x) t_1 (cbrt (pow (+ 1.0 x) 2.0)))))))
double code(double x) {
	return cbrt((x + 1.0)) - cbrt(x);
}
double code(double x) {
	double t_0 = cbrt((1.0 + x));
	double t_1 = cbrt(x) + t_0;
	double tmp;
	if ((t_0 - cbrt(x)) <= 0.0) {
		tmp = 1.0 / fma(cbrt(x), t_1, pow(cbrt(x), 2.0));
	} else {
		tmp = 1.0 / fma(cbrt(x), t_1, cbrt(pow((1.0 + x), 2.0)));
	}
	return tmp;
}
function code(x)
	return Float64(cbrt(Float64(x + 1.0)) - cbrt(x))
end
function code(x)
	t_0 = cbrt(Float64(1.0 + x))
	t_1 = Float64(cbrt(x) + t_0)
	tmp = 0.0
	if (Float64(t_0 - cbrt(x)) <= 0.0)
		tmp = Float64(1.0 / fma(cbrt(x), t_1, (cbrt(x) ^ 2.0)));
	else
		tmp = Float64(1.0 / fma(cbrt(x), t_1, cbrt((Float64(1.0 + x) ^ 2.0))));
	end
	return tmp
end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$1 + N[Power[N[Power[N[(1.0 + x), $MachinePrecision], 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\sqrt[3]{x + 1} - \sqrt[3]{x}
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := \sqrt[3]{x} + t_0\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) < 0.0

    1. Initial program 61.3

      \[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
    2. Applied egg-rr61.2

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}} \]
      Proof
      (/.f64 1 (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= metadata-eval (+.f64 1 0)) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 1 (Rewrite<= +-inverses_binary64 (-.f64 x x))) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 1 x) x)) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 123 points increase in error, 1 points decrease in error
      (/.f64 (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))) (pow.f64 (cbrt.f64 (+.f64 x 1)) 2)))): 2 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (-.f64 (+.f64 x 1) x) 1)) (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 (-.f64 (+.f64 x 1) x) (/.f64 1 (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))))))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr34.4

      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\color{blue}{\left(e^{0.3333333333333333 \cdot \mathsf{log1p}\left(x\right)}\right)}}^{2}\right)} \]
    5. Simplified34.1

      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\color{blue}{\left({\left(e^{0.3333333333333333}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)}\right)}}^{2}\right)} \]
      Proof
      (pow.f64 (exp.f64 1/3) (log1p.f64 x)): 0 points increase in error, 0 points decrease in error
      (Rewrite<= exp-prod_binary64 (exp.f64 (*.f64 1/3 (log1p.f64 x)))): 14 points increase in error, 42 points decrease in error
    6. Taylor expanded in x around inf 34.5

      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\color{blue}{\left({x}^{0.3333333333333333}\right)}}^{2}\right)} \]
    7. Simplified1.0

      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\color{blue}{\left(\sqrt[3]{x}\right)}}^{2}\right)} \]
      Proof
      (cbrt.f64 x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= unpow1/3_binary64 (pow.f64 x 1/3)): 139 points increase in error, 117 points decrease in error

    if 0.0 < (-.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))

    1. Initial program 1.2

      \[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
    2. Applied egg-rr0.1

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

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)}} \]
      Proof
      (/.f64 1 (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= metadata-eval (+.f64 1 0)) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (+.f64 1 (Rewrite<= +-inverses_binary64 (-.f64 x x))) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 1 x) x)) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 123 points increase in error, 1 points decrease in error
      (/.f64 (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1)) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 1 x)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (+.f64 1 x)) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (fma.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)) (pow.f64 (cbrt.f64 (Rewrite<= +-commutative_binary64 (+.f64 x 1))) 2))): 0 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))) (pow.f64 (cbrt.f64 (+.f64 x 1)) 2)))): 2 points increase in error, 0 points decrease in error
      (/.f64 (-.f64 (+.f64 x 1) x) (Rewrite<= +-commutative_binary64 (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x)))))): 0 points increase in error, 0 points decrease in error
      (/.f64 (Rewrite<= *-rgt-identity_binary64 (*.f64 (-.f64 (+.f64 x 1) x) 1)) (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate-*r/_binary64 (*.f64 (-.f64 (+.f64 x 1) x) (/.f64 1 (+.f64 (pow.f64 (cbrt.f64 (+.f64 x 1)) 2) (*.f64 (cbrt.f64 x) (+.f64 (cbrt.f64 (+.f64 x 1)) (cbrt.f64 x))))))): 0 points increase in error, 0 points decrease in error
    4. Applied egg-rr0.1

      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{1 + x} + \sqrt[3]{x}, \color{blue}{\sqrt[3]{{\left(1 + x\right)}^{2}}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + \sqrt[3]{1 + x}, \sqrt[3]{{\left(1 + x\right)}^{2}}\right)}\\ \end{array} \]

Alternatives

Alternative 1
Error0.5
Cost52228
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := \sqrt[3]{x} + t_0\\ \mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, {\left(\sqrt[3]{x}\right)}^{2}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + x\right) - x}{\sqrt[3]{{\left(1 + x\right)}^{2}} + \sqrt[3]{x} \cdot t_1}\\ \end{array} \]
Alternative 2
Error0.5
Cost39168
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, {t_0}^{2}\right)} \end{array} \]
Alternative 3
Error13.0
Cost33232
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := \sqrt[3]{x} + t_0\\ t_2 := \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, 1\right)}\\ t_3 := \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_1, \sqrt[3]{x \cdot x}\right)}\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -38000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 23000000:\\ \;\;\;\;t_0 - \sqrt[3]{x}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+154}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error7.8
Cost33032
\[\begin{array}{l} t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\ \mathbf{if}\;x \leq -1.35 \cdot 10^{+154}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, 1\right)}\\ \mathbf{elif}\;x \leq -1:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, \sqrt[3]{x \cdot x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\ \end{array} \]
Alternative 5
Error24.6
Cost32840
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+15}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+15}:\\ \;\;\;\;t_0 - \sqrt[3]{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, 1 + \sqrt[3]{x}, e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}\right)}\\ \end{array} \]
Alternative 6
Error25.7
Cost32640
\[\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, 1 + \sqrt[3]{x}, {\left(\sqrt[3]{1 + x}\right)}^{2}\right)} \]
Alternative 7
Error24.6
Cost26440
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ t_1 := \frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, 1\right)}\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+15}:\\ \;\;\;\;t_0 - \sqrt[3]{x}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error29.3
Cost13120
\[\sqrt[3]{1 + x} - \sqrt[3]{x} \]
Alternative 9
Error30.9
Cost6848
\[1 + \left(x \cdot 0.3333333333333333 - \sqrt[3]{x}\right) \]
Alternative 10
Error31.0
Cost6592
\[1 - \sqrt[3]{x} \]
Alternative 11
Error61.7
Cost64
\[0 \]
Alternative 12
Error31.4
Cost64
\[1 \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x)
  :name "2cbrt (problem 3.3.4)"
  :precision binary64
  (- (cbrt (+ x 1.0)) (cbrt x)))