Average Error: 29.8 → 0.5
Time: 7.7s
Precision: binary64
Cost: 52356
\[\sqrt[3]{x + 1} - \sqrt[3]{x} \]
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \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))))
   (if (<= (- t_0 (cbrt x)) 0.0)
     (/ (cbrt (/ 0.037037037037037035 x)) (cbrt x))
     (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (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 tmp;
	if ((t_0 - cbrt(x)) <= 0.0) {
		tmp = cbrt((0.037037037037037035 / x)) / cbrt(x);
	} else {
		tmp = 1.0 / fma(cbrt(x), (cbrt(x) + t_0), 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))
	tmp = 0.0
	if (Float64(t_0 - cbrt(x)) <= 0.0)
		tmp = Float64(cbrt(Float64(0.037037037037037035 / x)) / cbrt(x));
	else
		tmp = Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), 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]}, If[LessEqual[N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[Power[N[(0.037037037037037035 / x), $MachinePrecision], 1/3], $MachinePrecision] / N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + 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}\\
\mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\
\;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} + t_0, \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-rr62.6

      \[\leadsto \color{blue}{\left({\left(x + 1\right)}^{0.16666666666666666} + {x}^{0.16666666666666666}\right) \cdot \left({\left(x + 1\right)}^{0.16666666666666666} - {x}^{0.16666666666666666}\right)} \]
    3. Taylor expanded in x around inf 34.5

      \[\leadsto \color{blue}{0.3333333333333333 \cdot {\left(\frac{1}{{x}^{2}}\right)}^{0.3333333333333333}} \]
    4. Simplified32.4

      \[\leadsto \color{blue}{0.3333333333333333 \cdot \sqrt[3]{\frac{1}{x \cdot x}}} \]
      Proof
      (*.f64 1/3 (cbrt.f64 (/.f64 1 (*.f64 x x)))): 0 points increase in error, 0 points decrease in error
      (*.f64 1/3 (cbrt.f64 (/.f64 1 (Rewrite<= unpow2_binary64 (pow.f64 x 2))))): 0 points increase in error, 0 points decrease in error
      (*.f64 1/3 (Rewrite<= unpow1/3_binary64 (pow.f64 (/.f64 1 (pow.f64 x 2)) 1/3))): 55 points increase in error, 59 points decrease in error
    5. Applied egg-rr60.8

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

      \[\leadsto \color{blue}{\sqrt[3]{\frac{0.037037037037037035}{x \cdot x}}} \]
      Proof
      (cbrt.f64 (/.f64 1/27 (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1 1/27)) (*.f64 x x))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (/.f64 (*.f64 1 (Rewrite<= metadata-eval (pow.f64 1/3 3))) (*.f64 x x))): 24 points increase in error, 26 points decrease in error
      (cbrt.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 (*.f64 x x)) (pow.f64 1/3 3)))): 5 points increase in error, 4 points decrease in error
      (cbrt.f64 (*.f64 (Rewrite=> associate-/r*_binary64 (/.f64 (/.f64 1 x) x)) (pow.f64 1/3 3))): 12 points increase in error, 15 points decrease in error
      (cbrt.f64 (*.f64 (/.f64 (Rewrite<= *-lft-identity_binary64 (*.f64 1 (/.f64 1 x))) x) (pow.f64 1/3 3))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (*.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1 x) (/.f64 1 x))) (pow.f64 1/3 3))): 7 points increase in error, 8 points decrease in error
      (cbrt.f64 (*.f64 (*.f64 (Rewrite<= unpow-1_binary64 (pow.f64 x -1)) (/.f64 1 x)) (pow.f64 1/3 3))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (*.f64 (*.f64 (pow.f64 x -1) (Rewrite<= unpow-1_binary64 (pow.f64 x -1))) (pow.f64 1/3 3))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (*.f64 (Rewrite=> pow-sqr_binary64 (pow.f64 x (*.f64 2 -1))) (pow.f64 1/3 3))): 15 points increase in error, 7 points decrease in error
      (cbrt.f64 (*.f64 (pow.f64 x (Rewrite=> metadata-eval -2)) (pow.f64 1/3 3))): 0 points increase in error, 0 points decrease in error
      (cbrt.f64 (*.f64 (Rewrite<= rem-cube-cbrt_binary64 (pow.f64 (cbrt.f64 (pow.f64 x -2)) 3)) (pow.f64 1/3 3))): 47 points increase in error, 21 points decrease in error
      (cbrt.f64 (Rewrite<= cube-prod_binary64 (pow.f64 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3) 3))): 20 points increase in error, 22 points decrease in error
      (Rewrite=> rem-cbrt-cube_binary64 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3)): 16 points increase in error, 54 points decrease in error
      (Rewrite<= +-rgt-identity_binary64 (+.f64 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3) 0)): 0 points increase in error, 0 points decrease in error
      (+.f64 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3) (Rewrite<= metadata-eval (-.f64 1 1))): 0 points increase in error, 0 points decrease in error
      (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3) 1) 1)): 56 points increase in error, 4 points decrease in error
      (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 1 (*.f64 (cbrt.f64 (pow.f64 x -2)) 1/3))) 1): 0 points increase in error, 0 points decrease in error
    7. Applied egg-rr0.9

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

    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.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. 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))): 119 points increase in error, 0 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)))): 0 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{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \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
Cost46340
\[\begin{array}{l} t_0 := \sqrt[3]{1 + x}\\ \mathbf{if}\;t_0 - \sqrt[3]{x} \leq 0:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(1 + x\right) - x}{{t_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}\\ \end{array} \]
Alternative 2
Error0.9
Cost39364
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{1 + x} - \sqrt[3]{x} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{\mathsf{fma}\left(x, x, -1\right)}}{\sqrt[3]{x + -1}} - \sqrt[3]{x}\\ \end{array} \]
Alternative 3
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 4
Error0.8
Cost19912
\[\begin{array}{l} \mathbf{if}\;x \leq -22500000:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \mathbf{elif}\;x \leq 45000000:\\ \;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot \left({x}^{-0.5} \cdot \sqrt[3]{{x}^{-0.5}}\right)\\ \end{array} \]
Alternative 5
Error0.8
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -22500000:\\ \;\;\;\;0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}\\ \mathbf{elif}\;x \leq 45000000:\\ \;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{{\left(\sqrt[3]{x}\right)}^{2}}\\ \end{array} \]
Alternative 6
Error0.8
Cost13384
\[\begin{array}{l} \mathbf{if}\;x \leq -22500000:\\ \;\;\;\;\frac{\sqrt[3]{\frac{0.037037037037037035}{x}}}{\sqrt[3]{x}}\\ \mathbf{elif}\;x \leq 45000000:\\ \;\;\;\;\sqrt[3]{1 + x} - \sqrt[3]{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{{\left(\sqrt[3]{x}\right)}^{2}}\\ \end{array} \]
Alternative 7
Error3.1
Cost13320
\[\begin{array}{l} t_0 := 0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}\\ \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error3.1
Cost13320
\[\begin{array}{l} \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;0.3333333333333333 \cdot {\left(\sqrt[3]{x}\right)}^{-2}\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{{\left(\sqrt[3]{x}\right)}^{2}}\\ \end{array} \]
Alternative 9
Error11.7
Cost7048
\[\begin{array}{l} \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;\frac{0.3333333333333333}{\sqrt[3]{x \cdot x}}\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot {\left(\frac{1}{x}\right)}^{0.6666666666666666}\\ \end{array} \]
Alternative 10
Error11.5
Cost7048
\[\begin{array}{l} \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;\sqrt[3]{\frac{0.037037037037037035}{x} \cdot \frac{1}{x}}\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0.3333333333333333 \cdot {\left(\frac{1}{x}\right)}^{0.6666666666666666}\\ \end{array} \]
Alternative 11
Error18.0
Cost6984
\[\begin{array}{l} t_0 := \sqrt[3]{\frac{0.037037037037037035}{x \cdot x}}\\ \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error18.0
Cost6984
\[\begin{array}{l} \mathbf{if}\;x \leq -0.08:\\ \;\;\;\;\frac{0.3333333333333333}{\sqrt[3]{x \cdot x}}\\ \mathbf{elif}\;x \leq 0.19:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\frac{0.037037037037037035}{x \cdot x}}\\ \end{array} \]
Alternative 13
Error61.7
Cost64
\[0 \]
Alternative 14
Error32.0
Cost64
\[1 \]

Error

Reproduce

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