
(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 13 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
(if (<= b -5e+104)
(/ (* (fma (/ (* a (/ c b)) b) -1.5 2.0) (- b)) (* 3.0 a))
(if (<= b 3e-92)
(/ (+ (- b) (sqrt (fma b b (* (* -3.0 a) c)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e+104) {
tmp = (fma(((a * (c / b)) / b), -1.5, 2.0) * -b) / (3.0 * a);
} else if (b <= 3e-92) {
tmp = (-b + sqrt(fma(b, b, ((-3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e+104) tmp = Float64(Float64(fma(Float64(Float64(a * Float64(c / b)) / b), -1.5, 2.0) * Float64(-b)) / Float64(3.0 * a)); elseif (b <= 3e-92) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e+104], N[(N[(N[(N[(N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision] * -1.5 + 2.0), $MachinePrecision] * (-b)), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 3e-92], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{+104}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{a \cdot \frac{c}{b}}{b}, -1.5, 2\right) \cdot \left(-b\right)}{3 \cdot a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.9999999999999997e104Initial program 59.0%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6495.3
Applied rewrites95.3%
if -4.9999999999999997e104 < b < 3.00000000000000013e-92Initial program 78.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval78.1
Applied rewrites78.1%
if 3.00000000000000013e-92 < b Initial program 17.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.1
Applied rewrites89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -4.7e+103)
(/ (fma 0.5 (* a (/ c b)) (* -0.6666666666666666 b)) a)
(if (<= b 3e-92)
(/ (+ (- b) (sqrt (fma b b (* (* -3.0 a) c)))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.7e+103) {
tmp = fma(0.5, (a * (c / b)), (-0.6666666666666666 * b)) / a;
} else if (b <= 3e-92) {
tmp = (-b + sqrt(fma(b, b, ((-3.0 * a) * c)))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.7e+103) tmp = Float64(fma(0.5, Float64(a * Float64(c / b)), Float64(-0.6666666666666666 * b)) / a); elseif (b <= 3e-92) tmp = Float64(Float64(Float64(-b) + sqrt(fma(b, b, Float64(Float64(-3.0 * a) * c)))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.7e+103], N[(N[(0.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3e-92], N[(N[((-b) + N[Sqrt[N[(b * b + N[(N[(-3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.7 \cdot 10^{+103}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, a \cdot \frac{c}{b}, -0.6666666666666666 \cdot b\right)}{a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot a\right) \cdot c\right)}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.70000000000000033e103Initial program 59.0%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6495.2
Applied rewrites95.2%
Taylor expanded in a around 0
Applied rewrites95.3%
if -4.70000000000000033e103 < b < 3.00000000000000013e-92Initial program 78.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval78.1
Applied rewrites78.1%
if 3.00000000000000013e-92 < b Initial program 17.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.1
Applied rewrites89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -3.6e+103)
(/ (fma 0.5 (* a (/ c b)) (* -0.6666666666666666 b)) a)
(if (<= b 3e-92)
(* 0.3333333333333333 (/ (- (sqrt (fma (* c -3.0) a (* b b))) b) a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3.6e+103) {
tmp = fma(0.5, (a * (c / b)), (-0.6666666666666666 * b)) / a;
} else if (b <= 3e-92) {
tmp = 0.3333333333333333 * ((sqrt(fma((c * -3.0), a, (b * b))) - b) / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -3.6e+103) tmp = Float64(fma(0.5, Float64(a * Float64(c / b)), Float64(-0.6666666666666666 * b)) / a); elseif (b <= 3e-92) tmp = Float64(0.3333333333333333 * Float64(Float64(sqrt(fma(Float64(c * -3.0), a, Float64(b * b))) - b) / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -3.6e+103], N[(N[(0.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3e-92], 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[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3.6 \cdot 10^{+103}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, a \cdot \frac{c}{b}, -0.6666666666666666 \cdot b\right)}{a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{\sqrt{\mathsf{fma}\left(c \cdot -3, a, b \cdot b\right)} - b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -3.60000000000000017e103Initial program 59.0%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6495.2
Applied rewrites95.2%
Taylor expanded in a around 0
Applied rewrites95.3%
if -3.60000000000000017e103 < b < 3.00000000000000013e-92Initial program 78.1%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval78.1
Applied rewrites78.1%
Applied rewrites78.1%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
div-addN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
metadata-eval78.0
Applied rewrites78.0%
Applied rewrites77.8%
if 3.00000000000000013e-92 < b Initial program 17.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.1
Applied rewrites89.1%
Final simplification85.4%
(FPCore (a b c)
:precision binary64
(if (<= b -2.3e-83)
(/ (fma 0.5 (* a (/ c b)) (* -0.6666666666666666 b)) a)
(if (<= b 3e-92)
(/ (+ (- b) (sqrt (* (* c a) -3.0))) (* 3.0 a))
(* (/ c b) -0.5))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.3e-83) {
tmp = fma(0.5, (a * (c / b)), (-0.6666666666666666 * b)) / a;
} else if (b <= 3e-92) {
tmp = (-b + sqrt(((c * a) * -3.0))) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.3e-83) tmp = Float64(fma(0.5, Float64(a * Float64(c / b)), Float64(-0.6666666666666666 * b)) / a); elseif (b <= 3e-92) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(c * a) * -3.0))) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.3e-83], N[(N[(0.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 3e-92], N[(N[((-b) + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -3.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.3 \cdot 10^{-83}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, a \cdot \frac{c}{b}, -0.6666666666666666 \cdot b\right)}{a}\\
\mathbf{elif}\;b \leq 3 \cdot 10^{-92}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{\left(c \cdot a\right) \cdot -3}}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -2.2999999999999999e-83Initial program 72.0%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6488.2
Applied rewrites88.2%
Taylor expanded in a around 0
Applied rewrites88.2%
if -2.2999999999999999e-83 < b < 3.00000000000000013e-92Initial program 73.5%
Taylor expanded in a around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6467.8
Applied rewrites67.8%
if 3.00000000000000013e-92 < b Initial program 17.7%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6489.1
Applied rewrites89.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ (fma 0.5 (* a (/ c b)) (* -0.6666666666666666 b)) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma(0.5, (a * (c / b)), (-0.6666666666666666 * b)) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(fma(0.5, Float64(a * Float64(c / b)), Float64(-0.6666666666666666 * b)) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(0.5 * N[(a * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(-0.6666666666666666 * b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{\mathsf{fma}\left(0.5, a \cdot \frac{c}{b}, -0.6666666666666666 \cdot b\right)}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.1%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.9
Applied rewrites69.9%
Taylor expanded in a around 0
Applied rewrites70.0%
if -4.999999999999985e-310 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma (/ b a) -0.6666666666666666 (* 0.5 (/ c b))) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma((b / a), -0.6666666666666666, (0.5 * (c / b)));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(Float64(b / a), -0.6666666666666666, Float64(0.5 * Float64(c / b))); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(N[(b / a), $MachinePrecision] * -0.6666666666666666 + N[(0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(\frac{b}{a}, -0.6666666666666666, 0.5 \cdot \frac{c}{b}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.1%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.9
Applied rewrites69.9%
Taylor expanded in a around 0
Applied rewrites70.0%
Taylor expanded in a around inf
Applied rewrites3.6%
Taylor expanded in a around inf
Applied rewrites70.0%
if -4.999999999999985e-310 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (fma 0.5 (/ c b) (* (/ b a) -0.6666666666666666)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = fma(0.5, (c / b), ((b / a) * -0.6666666666666666));
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = fma(0.5, Float64(c / b), Float64(Float64(b / a) * -0.6666666666666666)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(0.5 * N[(c / b), $MachinePrecision] + N[(N[(b / a), $MachinePrecision] * -0.6666666666666666), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{c}{b}, \frac{b}{a} \cdot -0.6666666666666666\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.1%
Taylor expanded in b around -inf
mul-1-negN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
lower-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6469.9
Applied rewrites69.9%
Taylor expanded in a around inf
Applied rewrites70.0%
if -4.999999999999985e-310 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e-308) (/ (/ (* -2.0 b) 3.0) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = ((-2.0 * b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.6d-308) then
tmp = (((-2.0d0) * b) / 3.0d0) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = ((-2.0 * b) / 3.0) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e-308: tmp = ((-2.0 * b) / 3.0) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e-308) tmp = Float64(Float64(Float64(-2.0 * b) / 3.0) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.6e-308) tmp = ((-2.0 * b) / 3.0) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e-308], N[(N[(N[(-2.0 * b), $MachinePrecision] / 3.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{-308}:\\
\;\;\;\;\frac{\frac{-2 \cdot b}{3}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.6000000000000001e-308Initial program 74.1%
Taylor expanded in b around -inf
lower-*.f6469.3
Applied rewrites69.3%
lift-/.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6469.3
Applied rewrites69.3%
if 1.6000000000000001e-308 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e-308) (/ (* -2.0 b) (* 3.0 a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.6d-308) then
tmp = ((-2.0d0) * b) / (3.0d0 * a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = (-2.0 * b) / (3.0 * a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e-308: tmp = (-2.0 * b) / (3.0 * a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e-308) tmp = Float64(Float64(-2.0 * b) / Float64(3.0 * a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.6e-308) tmp = (-2.0 * b) / (3.0 * a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e-308], N[(N[(-2.0 * b), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{-308}:\\
\;\;\;\;\frac{-2 \cdot b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.6000000000000001e-308Initial program 74.1%
Taylor expanded in b around -inf
lower-*.f6469.3
Applied rewrites69.3%
if 1.6000000000000001e-308 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e-308) (/ (* -0.6666666666666666 b) a) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.6d-308) then
tmp = ((-0.6666666666666666d0) * b) / a
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = (-0.6666666666666666 * b) / a;
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e-308: tmp = (-0.6666666666666666 * b) / a else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e-308) tmp = Float64(Float64(-0.6666666666666666 * b) / a); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.6e-308) tmp = (-0.6666666666666666 * b) / a; else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e-308], N[(N[(-0.6666666666666666 * b), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{-308}:\\
\;\;\;\;\frac{-0.6666666666666666 \cdot b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.6000000000000001e-308Initial program 74.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
Applied rewrites69.2%
if 1.6000000000000001e-308 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b 1.6e-308) (* -0.6666666666666666 (/ b a)) (* (/ c b) -0.5)))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= 1.6d-308) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = (c / b) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= 1.6e-308) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = (c / b) * -0.5;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.6e-308: tmp = -0.6666666666666666 * (b / a) else: tmp = (c / b) * -0.5 return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.6e-308) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(Float64(c / b) * -0.5); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.6e-308) tmp = -0.6666666666666666 * (b / a); else tmp = (c / b) * -0.5; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.6e-308], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{-308}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} \cdot -0.5\\
\end{array}
\end{array}
if b < 1.6000000000000001e-308Initial program 74.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
if 1.6000000000000001e-308 < b Initial program 30.8%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f6474.1
Applied rewrites74.1%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (* -0.6666666666666666 (/ b a)) (/ 0.0 a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0 / a;
}
return tmp;
}
real(8) function code(a, b, c)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8) :: tmp
if (b <= (-5d-310)) then
tmp = (-0.6666666666666666d0) * (b / a)
else
tmp = 0.0d0 / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = -0.6666666666666666 * (b / a);
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = -0.6666666666666666 * (b / a) else: tmp = 0.0 / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(-0.6666666666666666 * Float64(b / a)); else tmp = Float64(0.0 / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = -0.6666666666666666 * (b / a); else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(-0.6666666666666666 * N[(b / a), $MachinePrecision]), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 74.1%
Taylor expanded in b around -inf
lower-*.f64N/A
lower-/.f6469.1
Applied rewrites69.1%
if -4.999999999999985e-310 < b Initial program 30.8%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval30.8
Applied rewrites30.8%
Applied rewrites30.8%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
div-addN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
metadata-eval28.1
Applied rewrites28.1%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inversesN/A
metadata-eval17.8
Applied rewrites17.8%
(FPCore (a b c) :precision binary64 (/ 0.0 a))
double code(double a, double b, double c) {
return 0.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 = 0.0d0 / a
end function
public static double code(double a, double b, double c) {
return 0.0 / a;
}
def code(a, b, c): return 0.0 / a
function code(a, b, c) return Float64(0.0 / a) end
function tmp = code(a, b, c) tmp = 0.0 / a; end
code[a_, b_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 49.7%
lift--.f64N/A
lift-*.f64N/A
fp-cancel-sub-sign-invN/A
lift-*.f64N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
metadata-eval49.7
Applied rewrites49.7%
Applied rewrites49.7%
lift-/.f64N/A
lift-neg.f64N/A
lift-+.f64N/A
div-addN/A
frac-addN/A
lower-/.f64N/A
lower-fma.f64N/A
lift-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
metadata-eval48.2
Applied rewrites48.2%
Taylor expanded in a around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
+-inversesN/A
metadata-eval11.2
Applied rewrites11.2%
herbie shell --seed 2024326
(FPCore (a b c)
:name "Cubic critical"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))