(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) { return cbrt((x + 1.0)) - cbrt(x); }
public static double code(double x) { return Math.cbrt((x + 1.0)) - Math.cbrt(x); }
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \sqrt[3]{x + 1} - \sqrt[3]{x} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) { return cbrt((x + 1.0)) - cbrt(x); }
public static double code(double x) { return Math.cbrt((x + 1.0)) - Math.cbrt(x); }
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \sqrt[3]{x + 1} - \sqrt[3]{x} \end{array}
(FPCore (x) :precision binary64 (- (cbrt (+ x 1.0)) (cbrt x)))
double code(double x) { return cbrt((x + 1.0)) - cbrt(x); }
public static double code(double x) { return Math.cbrt((x + 1.0)) - Math.cbrt(x); }
function code(x) return Float64(cbrt(Float64(x + 1.0)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \sqrt[3]{x + 1} - \sqrt[3]{x} \end{array}
Initial program 100.0%
(FPCore (x) :precision binary64 (fma (fma (fma 0.06172839506172839 x -0.1111111111111111) x 0.3333333333333333) x (- 1.0 (cbrt x))))
double code(double x) { return fma(fma(fma(0.06172839506172839, x, -0.1111111111111111), x, 0.3333333333333333), x, (1.0 - cbrt(x))); }
function code(x) return fma(fma(fma(0.06172839506172839, x, -0.1111111111111111), x, 0.3333333333333333), x, Float64(1.0 - cbrt(x))) end
code[x_] := N[(N[(N[(0.06172839506172839 * x + -0.1111111111111111), $MachinePrecision] * x + 0.3333333333333333), $MachinePrecision] * x + N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.06172839506172839, x, -0.1111111111111111\right), x, 0.3333333333333333\right), x, 1 - \sqrt[3]{x}\right) \end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutative
N/A
associate--l+
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
sub-neg
N/A
metadata-eval
N/A
lower-fma.f64
N/A
lower--.f64
N/A
lower-cbrt.f64
99.2
Applied rewrites99.2%
(FPCore (x) :precision binary64 (- (fma (fma -0.1111111111111111 x 0.3333333333333333) x 1.0) (cbrt x)))
double code(double x) { return fma(fma(-0.1111111111111111, x, 0.3333333333333333), x, 1.0) - cbrt(x); }
function code(x) return Float64(fma(fma(-0.1111111111111111, x, 0.3333333333333333), x, 1.0) - cbrt(x)) end
code[x_] := N[(N[(N[(-0.1111111111111111 * x + 0.3333333333333333), $MachinePrecision] * x + 1.0), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(-0.1111111111111111, x, 0.3333333333333333\right), x, 1\right) - \sqrt[3]{x} \end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutative
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
99.1
Applied rewrites99.1%
(FPCore (x) :precision binary64 (fma (fma -0.1111111111111111 x 0.3333333333333333) x (- 1.0 (cbrt x))))
double code(double x) { return fma(fma(-0.1111111111111111, x, 0.3333333333333333), x, (1.0 - cbrt(x))); }
function code(x) return fma(fma(-0.1111111111111111, x, 0.3333333333333333), x, Float64(1.0 - cbrt(x))) end
code[x_] := N[(N[(-0.1111111111111111 * x + 0.3333333333333333), $MachinePrecision] * x + N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(\mathsf{fma}\left(-0.1111111111111111, x, 0.3333333333333333\right), x, 1 - \sqrt[3]{x}\right) \end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutative
N/A
associate--l+
N/A
*-commutative
N/A
lower-fma.f64
N/A
+-commutative
N/A
lower-fma.f64
N/A
lower--.f64
N/A
lower-cbrt.f64
99.1
Applied rewrites99.1%
(FPCore (x) :precision binary64 (fma 0.3333333333333333 x (- 1.0 (cbrt x))))
double code(double x) { return fma(0.3333333333333333, x, (1.0 - cbrt(x))); }
function code(x) return fma(0.3333333333333333, x, Float64(1.0 - cbrt(x))) end
code[x_] := N[(0.3333333333333333 * x + N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \mathsf{fma}\left(0.3333333333333333, x, 1 - \sqrt[3]{x}\right) \end{array}
Initial program 100.0%
Taylor expanded in x around 0
+-commutative
N/A
associate--l+
N/A
lower-fma.f64
N/A
lower--.f64
N/A
lower-cbrt.f64
98.7
Applied rewrites98.7%
(FPCore (x) :precision binary64 (- 1.0 (cbrt x)))
double code(double x) { return 1.0 - cbrt(x); }
public static double code(double x) { return 1.0 - Math.cbrt(x); }
function code(x) return Float64(1.0 - cbrt(x)) end
code[x_] := N[(1.0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \sqrt[3]{x} \end{array}
Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites97.4%
herbie shell --seed 1
(FPCore (x)
:name "cbrt(x + 1) - cbrt(x)"
:precision binary64
:pre (and (<= -1.0 x) (<= x 1.0))
(- (cbrt (+ x 1.0)) (cbrt x)))