
(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 55.2%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites55.3%
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 rewrites54.3%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 260.0)
(/ (/ (- t_0 (* b b)) (* (+ (sqrt t_0) b) a)) 3.0)
(fma (* -0.375 a) (/ (/ (* c c) (* b 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 <= 260.0) {
tmp = ((t_0 - (b * b)) / ((sqrt(t_0) + b) * a)) / 3.0;
} else {
tmp = fma((-0.375 * a), (((c * c) / (b * 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 <= 260.0) tmp = Float64(Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(sqrt(t_0) + b) * a)) / 3.0); else tmp = fma(Float64(-0.375 * a), Float64(Float64(Float64(c * c) / Float64(b * b)) / b), Float64(-0.5 * Float64(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, 260.0], N[(N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision], N[(N[(-0.375 * a), $MachinePrecision] * N[(N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{\frac{t\_0 - b \cdot b}{\left(\sqrt{t\_0} + b\right) \cdot a}}{3}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375 \cdot a, \frac{\frac{c \cdot c}{b \cdot b}}{b}, -0.5 \cdot \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites77.7%
lift-/.f64N/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
lower-+.f6479.1
Applied rewrites79.1%
if 260 < b Initial program 43.5%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Applied rewrites90.6%
Final simplification86.7%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fma (* c -3.0) a (* b b))))
(if (<= b 260.0)
(/ (- t_0 (* b b)) (* (* 3.0 a) (+ (sqrt t_0) b)))
(fma (* -0.375 a) (/ (/ (* c c) (* b 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 <= 260.0) {
tmp = (t_0 - (b * b)) / ((3.0 * a) * (sqrt(t_0) + b));
} else {
tmp = fma((-0.375 * a), (((c * c) / (b * 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 <= 260.0) tmp = Float64(Float64(t_0 - Float64(b * b)) / Float64(Float64(3.0 * a) * Float64(sqrt(t_0) + b))); else tmp = fma(Float64(-0.375 * a), Float64(Float64(Float64(c * c) / Float64(b * b)) / b), Float64(-0.5 * Float64(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, 260.0], N[(N[(t$95$0 - N[(b * b), $MachinePrecision]), $MachinePrecision] / N[(N[(3.0 * a), $MachinePrecision] * N[(N[Sqrt[t$95$0], $MachinePrecision] + b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * a), $MachinePrecision] * N[(N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)\\
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{t\_0 - b \cdot b}{\left(3 \cdot a\right) \cdot \left(\sqrt{t\_0} + b\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375 \cdot a, \frac{\frac{c \cdot c}{b \cdot b}}{b}, -0.5 \cdot \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
lower-/.f64N/A
Applied rewrites77.7%
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 rewrites79.1%
if 260 < b Initial program 43.5%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Applied rewrites90.6%
Final simplification86.6%
(FPCore (a b c) :precision binary64 (if (<= b 260.0) (/ (- (sqrt (fma b b (* (* a -3.0) c))) b) (* 3.0 a)) (fma (* -0.375 a) (/ (/ (* c c) (* b b)) b) (* -0.5 (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= 260.0) {
tmp = (sqrt(fma(b, b, ((a * -3.0) * c))) - b) / (3.0 * a);
} else {
tmp = fma((-0.375 * a), (((c * c) / (b * b)) / b), (-0.5 * (c / b)));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 260.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(a * -3.0) * c))) - b) / Float64(3.0 * a)); else tmp = fma(Float64(-0.375 * a), Float64(Float64(Float64(c * c) / Float64(b * b)) / b), Float64(-0.5 * Float64(c / b))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 260.0], N[(N[(N[Sqrt[N[(b * b + N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(-0.375 * a), $MachinePrecision] * N[(N[(N[(c * c), $MachinePrecision] / N[(b * b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot -3\right) \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(-0.375 \cdot a, \frac{\frac{c \cdot c}{b \cdot b}}{b}, -0.5 \cdot \frac{c}{b}\right)\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval77.7
Applied rewrites77.7%
if 260 < b Initial program 43.5%
Taylor expanded in a around 0
+-commutativeN/A
associate-/l*N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
unpow2N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6490.6
Applied rewrites90.6%
Applied rewrites90.6%
Final simplification86.2%
(FPCore (a b c) :precision binary64 (if (<= b 260.0) (/ (- (sqrt (fma b b (* (* a -3.0) c))) b) (* 3.0 a)) (/ (fma (/ (* (* c c) -0.375) b) (/ a b) (* -0.5 c)) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 260.0) {
tmp = (sqrt(fma(b, b, ((a * -3.0) * c))) - b) / (3.0 * a);
} else {
tmp = fma((((c * c) * -0.375) / b), (a / b), (-0.5 * c)) / b;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 260.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(a * -3.0) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(fma(Float64(Float64(Float64(c * c) * -0.375) / b), Float64(a / b), Float64(-0.5 * c)) / b); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 260.0], N[(N[(N[Sqrt[N[(b * b + N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(c * c), $MachinePrecision] * -0.375), $MachinePrecision] / b), $MachinePrecision] * N[(a / b), $MachinePrecision] + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot -3\right) \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot -0.375}{b}, \frac{a}{b}, -0.5 \cdot c\right)}{b}\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval77.7
Applied rewrites77.7%
if 260 < b Initial program 43.5%
Taylor expanded in b around inf
lower-/.f64N/A
+-commutativeN/A
associate-*r/N/A
unpow2N/A
*-commutativeN/A
associate-*r*N/A
times-fracN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lower-/.f64N/A
lower-*.f6490.6
Applied rewrites90.6%
Final simplification86.2%
(FPCore (a b c) :precision binary64 (if (<= b 260.0) (/ (- (sqrt (fma b b (* (* a -3.0) c))) b) (* 3.0 a)) (* (/ (fma (* 0.375 a) (/ c (* b b)) 0.5) (- b)) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 260.0) {
tmp = (sqrt(fma(b, b, ((a * -3.0) * c))) - b) / (3.0 * a);
} else {
tmp = (fma((0.375 * a), (c / (b * b)), 0.5) / -b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 260.0) tmp = Float64(Float64(sqrt(fma(b, b, Float64(Float64(a * -3.0) * c))) - b) / Float64(3.0 * a)); else tmp = Float64(Float64(fma(Float64(0.375 * a), Float64(c / Float64(b * b)), 0.5) / Float64(-b)) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 260.0], N[(N[(N[Sqrt[N[(b * b + N[(N[(a * -3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.375 * a), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] / (-b)), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot -3\right) \cdot c\right)} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.375 \cdot a, \frac{c}{b \cdot b}, 0.5\right)}{-b} \cdot c\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval77.7
Applied rewrites77.7%
if 260 < b Initial program 43.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.4%
Taylor expanded in b around -inf
Applied rewrites90.2%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (if (<= b 260.0) (* 0.3333333333333333 (/ (- (sqrt (fma (* c -3.0) a (* b b))) b) a)) (* (/ (fma (* 0.375 a) (/ c (* b b)) 0.5) (- b)) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 260.0) {
tmp = 0.3333333333333333 * ((sqrt(fma((c * -3.0), a, (b * b))) - b) / a);
} else {
tmp = (fma((0.375 * a), (c / (b * b)), 0.5) / -b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 260.0) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / a)); else tmp = Float64(Float64(fma(Float64(0.375 * a), Float64(c / Float64(b * b)), 0.5) / Float64(-b)) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 260.0], N[(0.3333333333333333 * N[(N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.375 * a), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] / (-b)), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 260:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.375 \cdot a, \frac{c}{b \cdot b}, 0.5\right)}{-b} \cdot c\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift-/.f64N/A
lift-*.f64N/A
associate-/l/N/A
div-invN/A
lower-*.f64N/A
Applied rewrites77.7%
if 260 < b Initial program 43.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.4%
Taylor expanded in b around -inf
Applied rewrites90.2%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (if (<= b 260.0) (* (/ 0.3333333333333333 a) (- (sqrt (fma (* c -3.0) a (* b b))) b)) (* (/ (fma (* 0.375 a) (/ c (* b b)) 0.5) (- b)) c)))
double code(double a, double b, double c) {
double tmp;
if (b <= 260.0) {
tmp = (0.3333333333333333 / a) * (sqrt(fma((c * -3.0), a, (b * b))) - b);
} else {
tmp = (fma((0.375 * a), (c / (b * b)), 0.5) / -b) * c;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= 260.0) tmp = Float64(Float64(0.3333333333333333 / a) * Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b)); else tmp = Float64(Float64(fma(Float64(0.375 * a), Float64(c / Float64(b * b)), 0.5) / Float64(-b)) * c); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, 260.0], N[(N[(0.3333333333333333 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(c * -3.0), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.375 * a), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] / (-b)), $MachinePrecision] * c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 260:\\
\;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.375 \cdot a, \frac{c}{b \cdot b}, 0.5\right)}{-b} \cdot c\\
\end{array}
\end{array}
if b < 260Initial program 77.7%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
metadata-eval77.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6477.7
Applied rewrites77.7%
if 260 < b Initial program 43.5%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.4%
Taylor expanded in b around -inf
Applied rewrites90.2%
Final simplification85.9%
(FPCore (a b c) :precision binary64 (* (/ (fma (* 0.375 a) (/ c (* b b)) 0.5) (- b)) c))
double code(double a, double b, double c) {
return (fma((0.375 * a), (c / (b * b)), 0.5) / -b) * c;
}
function code(a, b, c) return Float64(Float64(fma(Float64(0.375 * a), Float64(c / Float64(b * b)), 0.5) / Float64(-b)) * c) end
code[a_, b_, c_] := N[(N[(N[(N[(0.375 * a), $MachinePrecision] * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + 0.5), $MachinePrecision] / (-b)), $MachinePrecision] * c), $MachinePrecision]
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(0.375 \cdot a, \frac{c}{b \cdot b}, 0.5\right)}{-b} \cdot c
\end{array}
Initial program 55.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.1%
Taylor expanded in b around -inf
Applied rewrites81.6%
(FPCore (a b c) :precision binary64 (* -0.5 (/ c b)))
double code(double a, double b, double c) {
return -0.5 * (c / b);
}
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) * (c / b)
end function
public static double code(double a, double b, double c) {
return -0.5 * (c / b);
}
def code(a, b, c): return -0.5 * (c / b)
function code(a, b, c) return Float64(-0.5 * Float64(c / b)) end
function tmp = code(a, b, c) tmp = -0.5 * (c / b); end
code[a_, b_, c_] := N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \frac{c}{b}
\end{array}
Initial program 55.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6464.7
Applied rewrites64.7%
Final simplification64.7%
(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 55.2%
Taylor expanded in c around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites88.1%
Taylor expanded in c around 0
Applied rewrites64.7%
herbie shell --seed 2024251
(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)))