
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\end{array}
(FPCore (a b c) :precision binary64 (/ (/ (* (/ c a) -3.0) (+ (/ b a) (/ (sqrt (fma (* c -3.0) a (* b b))) a))) 3.0))
double code(double a, double b, double c) {
return (((c / a) * -3.0) / ((b / a) + (sqrt(fma((c * -3.0), a, (b * b))) / a))) / 3.0;
}
function code(a, b, c) return Float64(Float64(Float64(Float64(c / a) * -3.0) / Float64(Float64(b / a) + Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) / a))) / 3.0) end
code[a_, b_, c_] := N[(N[(N[(N[(c / a), $MachinePrecision] * -3.0), $MachinePrecision] / N[(N[(b / a), $MachinePrecision] + N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{c}{a} \cdot -3}{\frac{b}{a} + \frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)}}{a}}}{3}
\end{array}
Initial program 57.9%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites58.0%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
flip--N/A
lower-/.f64N/A
lower--.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
pow2N/A
lower-pow.f64N/A
lower-/.f64N/A
Applied rewrites57.1%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 75.0)
(/ (- t_0 (* b b)) (* (+ (sqrt t_0) b) (* 3.0 a)))
(/ (fma -0.375 (/ (* (* c c) a) (* b b)) (* -0.5 c)) b))))
double code(double a, double b, double c) {
double t_0 = fma((c * -3.0), a, (b * b));
double tmp;
if (b <= 75.0) {
tmp = (t_0 - (b * b)) / ((sqrt(t_0) + b) * (3.0 * a));
} else {
tmp = fma(-0.375, (((c * c) * a) / (b * b)), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) t_0 = fma(Float64(c * -3.0), a, Float64(b * b)) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(sqrt(t_0) + b) * Float64(3.0 * a))); else tmp = Float64(fma(-0.375, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[b, 75.0], N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] * N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\frac{t\_0 - b \cdot b}{\left(\sqrt{t\_0} + b\right) \cdot \left(3 \cdot a\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift-/.f64N/A
associate-/l/N/A
lift--.f64N/A
flip--N/A
associate-/l/N/A
lower-/.f64N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
lower--.f64N/A
lower-*.f64N/A
Applied rewrites82.2%
if 75 < b Initial program 46.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites46.2%
lift--.f64N/A
flip--N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites46.9%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6489.0
Applied rewrites89.0%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (/ (* (- (sqrt (fma -3.0 (* a c) (* b b))) b) a) (* (* a a) 3.0)) (/ (fma -0.375 (/ (* (* c c) a) (* b b)) (* -0.5 c)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = ((sqrt(fma(-3.0, (a * c), (b * b))) - b) * a) / ((a * a) * 3.0);
} else {
tmp = fma(-0.375, (((c * c) * a) / (b * b)), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(Float64(sqrt(fma(-3.0, Float64(a * c), Float64(b * b))) - b) * a) / Float64(Float64(a * a) * 3.0)); else tmp = Float64(fma(-0.375, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * a), $MachinePrecision] / N[(N[(a * a), $MachinePrecision] * 3.0), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} - b\right) \cdot a}{\left(a \cdot a\right) \cdot 3}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Applied rewrites80.4%
if 75 < b Initial program 46.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites46.2%
lift--.f64N/A
flip--N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites46.9%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6489.0
Applied rewrites89.0%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (/ (* (- (sqrt (fma -3.0 (* a c) (* b b))) b) a) (* (* 3.0 a) a)) (/ (fma -0.375 (/ (* (* c c) a) (* b b)) (* -0.5 c)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = ((sqrt(fma(-3.0, (a * c), (b * b))) - b) * a) / ((3.0 * a) * a);
} else {
tmp = fma(-0.375, (((c * c) * a) / (b * b)), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(Float64(sqrt(fma(-3.0, Float64(a * c), Float64(b * b))) - b) * a) / Float64(Float64(3.0 * a) * a)); else tmp = Float64(fma(-0.375, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * a), $MachinePrecision] / N[(N[(3.0 * a), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} - b\right) \cdot a}{\left(3 \cdot a\right) \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Applied rewrites80.4%
if 75 < b Initial program 46.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites46.2%
lift--.f64N/A
flip--N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites46.9%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6489.0
Applied rewrites89.0%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (/ (- (sqrt (fma -3.0 (* a c) (* b b))) b) (* 3.0 a)) (/ (fma -0.375 (/ (* (* c c) a) (* b b)) (* -0.5 c)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = (sqrt(fma(-3.0, (a * c), (b * b))) - b) / (3.0 * a);
} else {
tmp = fma(-0.375, (((c * c) * a) / (b * b)), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(sqrt(fma(-3.0, Float64(a * c), Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(fma(-0.375, Float64(Float64(Float64(c * c) * a) / Float64(b * b)), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * N[(N[(N[(c * c), $MachinePrecision] * a), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Applied rewrites80.4%
if 75 < b Initial program 46.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites46.2%
lift--.f64N/A
flip--N/A
lift-sqrt.f64N/A
lift-sqrt.f64N/A
rem-square-sqrtN/A
lift-*.f64N/A
div-subN/A
lower--.f64N/A
lower-/.f64N/A
lower-+.f64N/A
lower-/.f64N/A
Applied rewrites46.9%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-*.f6489.0
Applied rewrites89.0%
Final simplification86.1%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (/ (- (sqrt (fma -3.0 (* a c) (* b b))) b) (* 3.0 a)) (* (/ (fma -0.375 (* (/ c (* b b)) a) -0.5) b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = (sqrt(fma(-3.0, (a * c), (b * b))) - b) / (3.0 * a);
} else {
tmp = (fma(-0.375, ((c / (b * b)) * a), -0.5) / b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(sqrt(fma(-3.0, Float64(a * c), Float64(b * b))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(fma(-0.375, Float64(Float64(c / Float64(b * b)) * a), -0.5) / b) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + -0.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{c}{b \cdot b} \cdot a, -0.5\right)}{b} \cdot c\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Applied rewrites80.4%
if 75 < b Initial program 46.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.1%
Taylor expanded in c around 0
Applied rewrites72.5%
Taylor expanded in b around inf
Applied rewrites88.8%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (* 0.3333333333333333 (/ (- (sqrt (fma -3.0 (* a c) (* b b))) b) a)) (* (/ (fma -0.375 (* (/ c (* b b)) a) -0.5) b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = 0.3333333333333333 * ((sqrt(fma(-3.0, (a * c), (b * b))) - b) / a);
} else {
tmp = (fma(-0.375, ((c / (b * b)) * a), -0.5) / b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(-3.0, Float64(a * c), Float64(b * b))) - b) / a)); else tmp = Float64(Float64(fma(-0.375, Float64(Float64(c / Float64(b * b)) * a), -0.5) / b) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(-3.0 * N[(a * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + -0.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(-3, a \cdot c, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{c}{b \cdot b} \cdot a, -0.5\right)}{b} \cdot c\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites80.4%
lift-/.f64N/A
lift--.f64N/A
div-subN/A
frac-subN/A
lower-/.f64N/A
lower--.f64N/A
lower-*.f64N/A
lower-*.f64N/A
lower-*.f6479.6
Applied rewrites79.6%
Applied rewrites80.4%
if 75 < b Initial program 46.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.1%
Taylor expanded in c around 0
Applied rewrites72.5%
Taylor expanded in b around inf
Applied rewrites88.8%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (if (<= b 75.0) (* (- (sqrt (fma (* c -3.0) a (* b b))) b) (/ 0.3333333333333333 a)) (* (/ (fma -0.375 (* (/ c (* b b)) a) -0.5) b) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 75.0) {
tmp = (sqrt(fma((c * -3.0), a, (b * b))) - b) * (0.3333333333333333 / a);
} else {
tmp = (fma(-0.375, ((c / (b * b)) * a), -0.5) / b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 75.0) tmp = Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) * Float64(0.3333333333333333 / a)); else tmp = Float64(Float64(fma(-0.375, Float64(Float64(c / Float64(b * b)) * a), -0.5) / b) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 75.0], N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(-0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + -0.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 75:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-0.375, \frac{c}{b \cdot b} \cdot a, -0.5\right)}{b} \cdot c\\
\end{array}
\end{array}
if b < 75Initial program 80.4%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval80.4
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6480.4
Applied rewrites80.4%
if 75 < b Initial program 46.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.1%
Taylor expanded in c around 0
Applied rewrites72.5%
Taylor expanded in b around inf
Applied rewrites88.8%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (* (/ (fma -0.375 (* (/ c (* b b)) a) -0.5) b) c))
double code(double a, double b, double c) {
return (fma(-0.375, ((c / (b * b)) * a), -0.5) / b) * c;
}
function code(a, b, c) return Float64(Float64(fma(-0.375, Float64(Float64(c / Float64(b * b)) * a), -0.5) / b) * c) end
code[a_, b_, c_] := N[(N[(N[(-0.375 * N[(N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] + -0.5), $MachinePrecision] / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(-0.375, \frac{c}{b \cdot b} \cdot a, -0.5\right)}{b} \cdot c
\end{array}
Initial program 57.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.9%
Taylor expanded in c around 0
Applied rewrites62.1%
Taylor expanded in b around inf
Applied rewrites78.8%
Final simplification78.8%
(FPCore (a b c) :precision binary64 (* (/ c b) -0.5))
double code(double a, double b, double c) {
return (c / b) * -0.5;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = (c / b) * (-0.5d0)
end function
public static double code(double a, double b, double c) {
return (c / b) * -0.5;
}
def code(a, b, c): return (c / b) * -0.5
function code(a, b, c) return Float64(Float64(c / b) * -0.5) end
function tmp = code(a, b, c) tmp = (c / b) * -0.5; end
code[a_, b_, c_] := N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b} \cdot -0.5
\end{array}
Initial program 57.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6462.1
Applied rewrites62.1%
(FPCore (a b c) :precision binary64 (* (/ -0.5 b) c))
double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
code = ((-0.5d0) / b) * c
end function
public static double code(double a, double b, double c) {
return (-0.5 / b) * c;
}
def code(a, b, c): return (-0.5 / b) * c
function code(a, b, c) return Float64(Float64(-0.5 / b) * c) end
function tmp = code(a, b, c) tmp = (-0.5 / b) * c; end
code[a_, b_, c_] := N[(N[(-0.5 / b), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{-0.5}{b} \cdot c
\end{array}
Initial program 57.9%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites84.9%
Taylor expanded in c around 0
Applied rewrites62.1%
herbie shell --seed 2024263
(FPCore (a b c)
:name "Cubic critical, narrow range"
:precision binary64
:pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))