
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.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) - ((4.0d0 * a) * c)))) / (2.0d0 * a)
end function
public static double code(double a, double b, double c) {
return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
def code(a, b, c): return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)) end
function tmp = code(a, b, c) tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a); end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e+112)
(/ b (- a))
(if (<= b 4.1e-48)
(/ (- (sqrt (- (* b b) (* c (* 4.0 a)))) b) (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e+112) {
tmp = b / -a;
} else if (b <= 4.1e-48) {
tmp = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 <= (-4.5d+112)) then
tmp = b / -a
else if (b <= 4.1d-48) then
tmp = (sqrt(((b * b) - (c * (4.0d0 * a)))) - b) / (a * 2.0d0)
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e+112) {
tmp = b / -a;
} else if (b <= 4.1e-48) {
tmp = (Math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -4.5e+112: tmp = b / -a elif b <= 4.1e-48: tmp = (math.sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0) else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -4.5e+112) tmp = Float64(b / Float64(-a)); elseif (b <= 4.1e-48) tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(c * Float64(4.0 * a)))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -4.5e+112) tmp = b / -a; elseif (b <= 4.1e-48) tmp = (sqrt(((b * b) - (c * (4.0 * a)))) - b) / (a * 2.0); else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -4.5e+112], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 4.1e-48], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(c * N[(4.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{+112}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - c \cdot \left(4 \cdot a\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.4999999999999999e112Initial program 43.8%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6495.3
Applied rewrites95.3%
if -4.4999999999999999e112 < b < 4.10000000000000014e-48Initial program 82.4%
if 4.10000000000000014e-48 < b Initial program 14.2%
Applied rewrites14.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f6414.2
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6414.2
Applied rewrites14.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
Final simplification87.4%
(FPCore (a b c)
:precision binary64
(if (<= b -4.5e+112)
(/ b (- a))
(if (<= b 4.1e-48)
(* (/ -0.5 a) (- b (sqrt (fma c (* a -4.0) (* b b)))))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -4.5e+112) {
tmp = b / -a;
} else if (b <= 4.1e-48) {
tmp = (-0.5 / a) * (b - sqrt(fma(c, (a * -4.0), (b * b))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -4.5e+112) tmp = Float64(b / Float64(-a)); elseif (b <= 4.1e-48) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(fma(c, Float64(a * -4.0), Float64(b * b))))); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -4.5e+112], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 4.1e-48], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -4.5 \cdot 10^{+112}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 4.1 \cdot 10^{-48}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.4999999999999999e112Initial program 43.8%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6495.3
Applied rewrites95.3%
if -4.4999999999999999e112 < b < 4.10000000000000014e-48Initial program 82.4%
Applied rewrites82.2%
if 4.10000000000000014e-48 < b Initial program 14.2%
Applied rewrites14.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f6414.2
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6414.2
Applied rewrites14.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-48)
(fma b (/ c (* b b)) (/ b (- a)))
(if (<= b 4e-48)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-48) {
tmp = fma(b, (c / (b * b)), (b / -a));
} else if (b <= 4e-48) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-48) tmp = fma(b, Float64(c / Float64(b * b)), Float64(b / Float64(-a))); elseif (b <= 4e-48) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-48], N[(b * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(b / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-48], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{c}{b \cdot b}, \frac{b}{-a}\right)\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.5e-48Initial program 61.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6491.9
Applied rewrites91.9%
if -1.5e-48 < b < 3.9999999999999999e-48Initial program 78.8%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.4
Applied rewrites73.4%
if 3.9999999999999999e-48 < b Initial program 14.2%
Applied rewrites14.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f6414.2
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6414.2
Applied rewrites14.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
Final simplification85.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.5e-48)
(fma b (/ c (* b b)) (/ b (- a)))
(if (<= b 4e-48)
(* (/ -0.5 a) (- b (sqrt (* c (* a -4.0)))))
(/ 1.0 (- (/ a b) (/ b c))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.5e-48) {
tmp = fma(b, (c / (b * b)), (b / -a));
} else if (b <= 4e-48) {
tmp = (-0.5 / a) * (b - sqrt((c * (a * -4.0))));
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.5e-48) tmp = fma(b, Float64(c / Float64(b * b)), Float64(b / Float64(-a))); elseif (b <= 4e-48) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(Float64(c * Float64(a * -4.0))))); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.5e-48], N[(b * N[(c / N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(b / (-a)), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 4e-48], N[(N[(-0.5 / a), $MachinePrecision] * N[(b - N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.5 \cdot 10^{-48}:\\
\;\;\;\;\mathsf{fma}\left(b, \frac{c}{b \cdot b}, \frac{b}{-a}\right)\\
\mathbf{elif}\;b \leq 4 \cdot 10^{-48}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -1.5e-48Initial program 61.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-*l/N/A
*-lft-identityN/A
*-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-outN/A
remove-double-negN/A
lower-fma.f64N/A
lower-/.f64N/A
unpow2N/A
lower-*.f64N/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6491.9
Applied rewrites91.9%
if -1.5e-48 < b < 3.9999999999999999e-48Initial program 78.8%
Applied rewrites78.7%
Taylor expanded in c around inf
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.3
Applied rewrites73.3%
if 3.9999999999999999e-48 < b Initial program 14.2%
Applied rewrites14.2%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f6414.2
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6414.2
Applied rewrites14.2%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6488.7
Applied rewrites88.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) (/ 1.0 (- (/ a b) (/ b c)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
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 = b / -a
else
tmp = 1.0d0 / ((a / b) - (b / c))
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = 1.0 / ((a / b) - (b / c));
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = 1.0 / ((a / b) - (b / c)) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(1.0 / Float64(Float64(a / b) - Float64(b / c))); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / -a; else tmp = 1.0 / ((a / b) - (b / c)); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], N[(1.0 / N[(N[(a / b), $MachinePrecision] - N[(b / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{a}{b} - \frac{b}{c}}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6471.3
Applied rewrites71.3%
if -4.999999999999985e-310 < b Initial program 35.4%
Applied rewrites35.4%
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
clear-numN/A
div-invN/A
metadata-evalN/A
lift-*.f64N/A
un-div-invN/A
clear-numN/A
lower-/.f64N/A
lower-/.f6435.3
lift-fma.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6435.3
Applied rewrites35.3%
Taylor expanded in a around 0
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f64N/A
lower-/.f64N/A
lower-/.f6463.7
Applied rewrites63.7%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ b (- a)) (/ c (- b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
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 = b / -a
else
tmp = c / -b
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = b / -a;
} else {
tmp = c / -b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = b / -a else: tmp = c / -b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(b / Float64(-a)); else tmp = Float64(c / Float64(-b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = b / -a; else tmp = c / -b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(b / (-a)), $MachinePrecision], N[(c / (-b)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{-b}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 67.1%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6471.3
Applied rewrites71.3%
if -4.999999999999985e-310 < b Initial program 35.4%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6463.2
Applied rewrites63.2%
(FPCore (a b c) :precision binary64 (/ b (- a)))
double code(double a, double b, double c) {
return b / -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 / -a
end function
public static double code(double a, double b, double c) {
return b / -a;
}
def code(a, b, c): return b / -a
function code(a, b, c) return Float64(b / Float64(-a)) end
function tmp = code(a, b, c) tmp = b / -a; end
code[a_, b_, c_] := N[(b / (-a)), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{-a}
\end{array}
Initial program 51.3%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6437.1
Applied rewrites37.1%
herbie shell --seed 2024234
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))