
(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 14 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
(let* ((t_0 (cbrt (+ 1.0 x))))
(/
1.0
(+
(/ t_0 (/ 1.0 t_0))
(*
(cbrt x)
(/ (+ x (+ 1.0 x)) (fma (cbrt x) (- (cbrt x) t_0) (pow t_0 2.0))))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / ((t_0 / (1.0 / t_0)) + (cbrt(x) * ((x + (1.0 + x)) / fma(cbrt(x), (cbrt(x) - t_0), pow(t_0, 2.0)))));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64(Float64(t_0 / Float64(1.0 / t_0)) + Float64(cbrt(x) * Float64(Float64(x + Float64(1.0 + x)) / fma(cbrt(x), Float64(cbrt(x) - t_0), (t_0 ^ 2.0)))))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[(x + N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] - t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\frac{t_0}{\frac{1}{t_0}} + \sqrt[3]{x} \cdot \frac{x + \left(1 + x\right)}{\mathsf{fma}\left(\sqrt[3]{x}, \sqrt[3]{x} - t_0, {t_0}^{2}\right)}}
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (cbrt (+ 1.0 x))) (t_1 (- t_0 (cbrt x))))
(if (<= t_1 2e-6)
(/ 1.0 (+ (* (cbrt x) (+ (cbrt x) t_0)) (cbrt (pow x 2.0))))
(exp (* (* 3.0 (log t_1)) 0.3333333333333333)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
double t_1 = t_0 - cbrt(x);
double tmp;
if (t_1 <= 2e-6) {
tmp = 1.0 / ((cbrt(x) * (cbrt(x) + t_0)) + cbrt(pow(x, 2.0)));
} else {
tmp = exp(((3.0 * log(t_1)) * 0.3333333333333333));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
double t_1 = t_0 - Math.cbrt(x);
double tmp;
if (t_1 <= 2e-6) {
tmp = 1.0 / ((Math.cbrt(x) * (Math.cbrt(x) + t_0)) + Math.cbrt(Math.pow(x, 2.0)));
} else {
tmp = Math.exp(((3.0 * Math.log(t_1)) * 0.3333333333333333));
}
return tmp;
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) t_1 = Float64(t_0 - cbrt(x)) tmp = 0.0 if (t_1 <= 2e-6) tmp = Float64(1.0 / Float64(Float64(cbrt(x) * Float64(cbrt(x) + t_0)) + cbrt((x ^ 2.0)))); else tmp = exp(Float64(Float64(3.0 * log(t_1)) * 0.3333333333333333)); end return tmp end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 2e-6], N[(1.0 / N[(N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(3.0 * N[Log[t$95$1], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
t_1 := t_0 - \sqrt[3]{x}\\
\mathbf{if}\;t_1 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right) + \sqrt[3]{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(3 \cdot \log t_1\right) \cdot 0.3333333333333333}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (fma (cbrt x) (+ (cbrt x) t_0) (pow t_0 2.0)))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / fma(cbrt(x), (cbrt(x) + t_0), pow(t_0, 2.0));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / fma(cbrt(x), Float64(cbrt(x) + t_0), (t_0 ^ 2.0))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\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}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (/ t_0 (/ 1.0 t_0)) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / ((t_0 / (1.0 / t_0)) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / ((t_0 / (1.0 / t_0)) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64(Float64(t_0 / Float64(1.0 / t_0)) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[(t$95$0 / N[(1.0 / t$95$0), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{\frac{t_0}{\frac{1}{t_0}} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))))))
(if (<= x -1.0)
(/ 1.0 (+ t_0 (cbrt (pow x 2.0))))
(/ 1.0 (+ t_0 (exp (* 0.6666666666666666 (log1p x))))))))
double code(double x) {
double t_0 = cbrt(x) * (cbrt(x) + cbrt((1.0 + x)));
double tmp;
if (x <= -1.0) {
tmp = 1.0 / (t_0 + cbrt(pow(x, 2.0)));
} else {
tmp = 1.0 / (t_0 + exp((0.6666666666666666 * log1p(x))));
}
return tmp;
}
public static double code(double x) {
double t_0 = Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)));
double tmp;
if (x <= -1.0) {
tmp = 1.0 / (t_0 + Math.cbrt(Math.pow(x, 2.0)));
} else {
tmp = 1.0 / (t_0 + Math.exp((0.6666666666666666 * Math.log1p(x))));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 / Float64(t_0 + cbrt((x ^ 2.0)))); else tmp = Float64(1.0 / Float64(t_0 + exp(Float64(0.6666666666666666 * log1p(x))))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(1.0 / N[(t$95$0 + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$0 + N[Exp[N[(0.6666666666666666 * N[Log[1 + x], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{1}{t_0 + \sqrt[3]{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0 + e^{0.6666666666666666 \cdot \mathsf{log1p}\left(x\right)}}\\
\end{array}
\end{array}
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (cbrt x) (cbrt (+ 1.0 x)))))
(if (<= x -1.0)
(/ 1.0 (+ (* (cbrt x) t_0) (cbrt (pow x 2.0))))
(/ 1.0 (fma (cbrt x) t_0 (pow (+ 1.0 x) 0.6666666666666666))))))
double code(double x) {
double t_0 = cbrt(x) + cbrt((1.0 + x));
double tmp;
if (x <= -1.0) {
tmp = 1.0 / ((cbrt(x) * t_0) + cbrt(pow(x, 2.0)));
} else {
tmp = 1.0 / fma(cbrt(x), t_0, pow((1.0 + x), 0.6666666666666666));
}
return tmp;
}
function code(x) t_0 = Float64(cbrt(x) + cbrt(Float64(1.0 + x))) tmp = 0.0 if (x <= -1.0) tmp = Float64(1.0 / Float64(Float64(cbrt(x) * t_0) + cbrt((x ^ 2.0)))); else tmp = Float64(1.0 / fma(cbrt(x), t_0, (Float64(1.0 + x) ^ 0.6666666666666666))); end return tmp end
code[x_] := Block[{t$95$0 = N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.0], N[(1.0 / N[(N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Power[x, 2.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[Power[x, 1/3], $MachinePrecision] * t$95$0 + N[Power[N[(1.0 + x), $MachinePrecision], 0.6666666666666666], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{x} + \sqrt[3]{1 + x}\\
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{1}{\sqrt[3]{x} \cdot t_0 + \sqrt[3]{{x}^{2}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt[3]{x}, t_0, {\left(1 + x\right)}^{0.6666666666666666}\right)}\\
\end{array}
\end{array}
(FPCore (x) :precision binary64 (let* ((t_0 (cbrt (+ 1.0 x)))) (/ 1.0 (+ (pow t_0 2.0) (* (cbrt x) (+ (cbrt x) t_0))))))
double code(double x) {
double t_0 = cbrt((1.0 + x));
return 1.0 / (pow(t_0, 2.0) + (cbrt(x) * (cbrt(x) + t_0)));
}
public static double code(double x) {
double t_0 = Math.cbrt((1.0 + x));
return 1.0 / (Math.pow(t_0, 2.0) + (Math.cbrt(x) * (Math.cbrt(x) + t_0)));
}
function code(x) t_0 = cbrt(Float64(1.0 + x)) return Float64(1.0 / Float64((t_0 ^ 2.0) + Float64(cbrt(x) * Float64(cbrt(x) + t_0)))) end
code[x_] := Block[{t$95$0 = N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]}, N[(1.0 / N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt[3]{1 + x}\\
\frac{1}{{t_0}^{2} + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + t_0\right)}
\end{array}
\end{array}
(FPCore (x) :precision binary64 (exp (- (log1p (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x))))))))
double code(double x) {
return exp(-log1p((cbrt(x) * (cbrt(x) + cbrt((1.0 + x))))));
}
public static double code(double x) {
return Math.exp(-Math.log1p((Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x))))));
}
function code(x) return exp(Float64(-log1p(Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x))))))) end
code[x_] := N[Exp[(-N[Log[1 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])], $MachinePrecision]
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(\sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)\right)}
\end{array}
(FPCore (x) :precision binary64 (/ 1.0 (+ 1.0 (* (cbrt x) (+ (cbrt x) (cbrt (+ 1.0 x)))))))
double code(double x) {
return 1.0 / (1.0 + (cbrt(x) * (cbrt(x) + cbrt((1.0 + x)))));
}
public static double code(double x) {
return 1.0 / (1.0 + (Math.cbrt(x) * (Math.cbrt(x) + Math.cbrt((1.0 + x)))));
}
function code(x) return Float64(1.0 / Float64(1.0 + Float64(cbrt(x) * Float64(cbrt(x) + cbrt(Float64(1.0 + x)))))) end
code[x_] := N[(1.0 / N[(1.0 + N[(N[Power[x, 1/3], $MachinePrecision] * N[(N[Power[x, 1/3], $MachinePrecision] + N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{1 + \sqrt[3]{x} \cdot \left(\sqrt[3]{x} + \sqrt[3]{1 + x}\right)}
\end{array}
(FPCore (x) :precision binary64 (fabs (- (/ 1.0 (/ 1.0 (cbrt (+ 1.0 x)))) (cbrt x))))
double code(double x) {
return fabs(((1.0 / (1.0 / cbrt((1.0 + x)))) - cbrt(x)));
}
public static double code(double x) {
return Math.abs(((1.0 / (1.0 / Math.cbrt((1.0 + x)))) - Math.cbrt(x)));
}
function code(x) return abs(Float64(Float64(1.0 / Float64(1.0 / cbrt(Float64(1.0 + x)))) - cbrt(x))) end
code[x_] := N[Abs[N[(N[(1.0 / N[(1.0 / N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\frac{1}{\frac{1}{\sqrt[3]{1 + x}}} - \sqrt[3]{x}\right|
\end{array}
(FPCore (x) :precision binary64 (fabs (- (cbrt x) (cbrt (+ 1.0 x)))))
double code(double x) {
return fabs((cbrt(x) - cbrt((1.0 + x))));
}
public static double code(double x) {
return Math.abs((Math.cbrt(x) - Math.cbrt((1.0 + x))));
}
function code(x) return abs(Float64(cbrt(x) - cbrt(Float64(1.0 + x)))) end
code[x_] := N[Abs[N[(N[Power[x, 1/3], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\left|\sqrt[3]{x} - \sqrt[3]{1 + x}\right|
\end{array}
(FPCore (x) :precision binary64 (- (cbrt (+ 1.0 x)) (cbrt x)))
double code(double x) {
return cbrt((1.0 + x)) - cbrt(x);
}
public static double code(double x) {
return Math.cbrt((1.0 + x)) - Math.cbrt(x);
}
function code(x) return Float64(cbrt(Float64(1.0 + x)) - cbrt(x)) end
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, 1/3], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\sqrt[3]{1 + x} - \sqrt[3]{x}
\end{array}
(FPCore (x) :precision binary64 0.0)
double code(double x) {
return 0.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 0.0d0
end function
public static double code(double x) {
return 0.0;
}
def code(x): return 0.0
function code(x) return 0.0 end
function tmp = code(x) tmp = 0.0; end
code[x_] := 0.0
\begin{array}{l}
\\
0
\end{array}
(FPCore (x) :precision binary64 1.0)
double code(double x) {
return 1.0;
}
real(8) function code(x)
real(8), intent (in) :: x
code = 1.0d0
end function
public static double code(double x) {
return 1.0;
}
def code(x): return 1.0
function code(x) return 1.0 end
function tmp = code(x) tmp = 1.0; end
code[x_] := 1.0
\begin{array}{l}
\\
1
\end{array}
herbie shell --seed 2023343
(FPCore (x)
:name "2cbrt (problem 3.3.4)"
:precision binary64
(- (cbrt (+ x 1.0)) (cbrt x)))