
(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 9 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 -2.7e+158)
(/ (- b) a)
(if (<= b 4.5e-273)
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a))
(if (<= b 1.32e+154)
(/ (* 2.0 c) (- (- b) (sqrt (fma (* -4.0 c) a (* b b)))))
(/ 0.5 (fma (/ a b) 0.5 (* (/ b c) -0.5)))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.7e+158) {
tmp = -b / a;
} else if (b <= 4.5e-273) {
tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
} else if (b <= 1.32e+154) {
tmp = (2.0 * c) / (-b - sqrt(fma((-4.0 * c), a, (b * b))));
} else {
tmp = 0.5 / fma((a / b), 0.5, ((b / c) * -0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.7e+158) tmp = Float64(Float64(-b) / a); elseif (b <= 4.5e-273) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a)); elseif (b <= 1.32e+154) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))))); else tmp = Float64(0.5 / fma(Float64(a / b), 0.5, Float64(Float64(b / c) * -0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.7e+158], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 4.5e-273], 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], If[LessEqual[b, 1.32e+154], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(N[(a / b), $MachinePrecision] * 0.5 + N[(N[(b / c), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.7 \cdot 10^{+158}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 4.5 \cdot 10^{-273}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\
\mathbf{elif}\;b \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\mathsf{fma}\left(\frac{a}{b}, 0.5, \frac{b}{c} \cdot -0.5\right)}\\
\end{array}
\end{array}
if b < -2.69999999999999979e158Initial program 39.0%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6497.5
Applied rewrites97.5%
if -2.69999999999999979e158 < b < 4.4999999999999996e-273Initial program 87.3%
if 4.4999999999999996e-273 < b < 1.31999999999999998e154Initial program 43.9%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6443.8
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6443.8
Applied rewrites43.8%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6443.8
lift-*.f64N/A
*-commutativeN/A
lower-*.f6443.8
Applied rewrites43.8%
Applied rewrites74.0%
Taylor expanded in a around 0
lower-*.f6489.7
Applied rewrites89.7%
if 1.31999999999999998e154 < b Initial program 1.6%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f641.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f641.6
Applied rewrites1.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (fma (* -4.0 c) a (* b b)))))
(if (<= b -7e+82)
(/ (- b) a)
(if (<= b 2.9e-273)
(* (/ 0.5 a) (- t_0 b))
(if (<= b 1.32e+154)
(/ (* 2.0 c) (- (- b) t_0))
(/ 0.5 (fma (/ a b) 0.5 (* (/ b c) -0.5))))))))
double code(double a, double b, double c) {
double t_0 = sqrt(fma((-4.0 * c), a, (b * b)));
double tmp;
if (b <= -7e+82) {
tmp = -b / a;
} else if (b <= 2.9e-273) {
tmp = (0.5 / a) * (t_0 - b);
} else if (b <= 1.32e+154) {
tmp = (2.0 * c) / (-b - t_0);
} else {
tmp = 0.5 / fma((a / b), 0.5, ((b / c) * -0.5));
}
return tmp;
}
function code(a, b, c) t_0 = sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))) tmp = 0.0 if (b <= -7e+82) tmp = Float64(Float64(-b) / a); elseif (b <= 2.9e-273) tmp = Float64(Float64(0.5 / a) * Float64(t_0 - b)); elseif (b <= 1.32e+154) tmp = Float64(Float64(2.0 * c) / Float64(Float64(-b) - t_0)); else tmp = Float64(0.5 / fma(Float64(a / b), 0.5, Float64(Float64(b / c) * -0.5))); end return tmp end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b, -7e+82], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 2.9e-273], N[(N[(0.5 / a), $MachinePrecision] * N[(t$95$0 - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.32e+154], N[(N[(2.0 * c), $MachinePrecision] / N[((-b) - t$95$0), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(N[(a / b), $MachinePrecision] * 0.5 + N[(N[(b / c), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)}\\
\mathbf{if}\;b \leq -7 \cdot 10^{+82}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 2.9 \cdot 10^{-273}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(t\_0 - b\right)\\
\mathbf{elif}\;b \leq 1.32 \cdot 10^{+154}:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - t\_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\mathsf{fma}\left(\frac{a}{b}, 0.5, \frac{b}{c} \cdot -0.5\right)}\\
\end{array}
\end{array}
if b < -7.0000000000000001e82Initial program 54.8%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6498.2
Applied rewrites98.2%
if -7.0000000000000001e82 < b < 2.89999999999999986e-273Initial program 84.8%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6484.5
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6484.5
Applied rewrites84.5%
if 2.89999999999999986e-273 < b < 1.31999999999999998e154Initial program 45.2%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6445.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6445.1
Applied rewrites45.1%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
lower-*.f64N/A
lower-/.f6445.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6445.2
Applied rewrites45.2%
Applied rewrites74.6%
Taylor expanded in a around 0
lower-*.f6489.9
Applied rewrites89.9%
if 1.31999999999999998e154 < b Initial program 1.6%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f641.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f641.6
Applied rewrites1.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6499.8
Applied rewrites99.8%
(FPCore (a b c)
:precision binary64
(if (<= b -7e+82)
(/ (- b) a)
(if (<= b 1.8e-110)
(* (/ 0.5 a) (- (sqrt (fma (* -4.0 c) a (* b b))) b))
(/ 0.5 (fma (/ a b) 0.5 (* (/ b c) -0.5))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -7e+82) {
tmp = -b / a;
} else if (b <= 1.8e-110) {
tmp = (0.5 / a) * (sqrt(fma((-4.0 * c), a, (b * b))) - b);
} else {
tmp = 0.5 / fma((a / b), 0.5, ((b / c) * -0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -7e+82) tmp = Float64(Float64(-b) / a); elseif (b <= 1.8e-110) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(fma(Float64(-4.0 * c), a, Float64(b * b))) - b)); else tmp = Float64(0.5 / fma(Float64(a / b), 0.5, Float64(Float64(b / c) * -0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -7e+82], N[((-b) / a), $MachinePrecision], If[LessEqual[b, 1.8e-110], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(N[(-4.0 * c), $MachinePrecision] * a + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(N[(a / b), $MachinePrecision] * 0.5 + N[(N[(b / c), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -7 \cdot 10^{+82}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{elif}\;b \leq 1.8 \cdot 10^{-110}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{\mathsf{fma}\left(-4 \cdot c, a, b \cdot b\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\mathsf{fma}\left(\frac{a}{b}, 0.5, \frac{b}{c} \cdot -0.5\right)}\\
\end{array}
\end{array}
if b < -7.0000000000000001e82Initial program 54.8%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6498.2
Applied rewrites98.2%
if -7.0000000000000001e82 < b < 1.79999999999999997e-110Initial program 81.3%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6481.0
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6481.0
Applied rewrites81.0%
if 1.79999999999999997e-110 < b Initial program 17.6%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6417.6
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6417.6
Applied rewrites17.6%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6487.9
Applied rewrites87.9%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e-38)
(- (/ c b) (/ b a))
(if (<= b 5.4e-141)
(/ (+ (- b) (sqrt (* -4.0 (* c a)))) (* 2.0 a))
(/ 0.5 (fma (/ a b) 0.5 (* (/ b c) -0.5))))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e-38) {
tmp = (c / b) - (b / a);
} else if (b <= 5.4e-141) {
tmp = (-b + sqrt((-4.0 * (c * a)))) / (2.0 * a);
} else {
tmp = 0.5 / fma((a / b), 0.5, ((b / c) * -0.5));
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e-38) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.4e-141) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-4.0 * Float64(c * a)))) / Float64(2.0 * a)); else tmp = Float64(0.5 / fma(Float64(a / b), 0.5, Float64(Float64(b / c) * -0.5))); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e-38], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-141], N[(N[((-b) + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[(0.5 / N[(N[(a / b), $MachinePrecision] * 0.5 + N[(N[(b / c), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{-38}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-141}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{\mathsf{fma}\left(\frac{a}{b}, 0.5, \frac{b}{c} \cdot -0.5\right)}\\
\end{array}
\end{array}
if b < -1.59999999999999989e-38Initial program 69.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
associate-*l/N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6492.7
Applied rewrites92.7%
Applied rewrites92.7%
if -1.59999999999999989e-38 < b < 5.4000000000000005e-141Initial program 77.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
Applied rewrites70.8%
if 5.4000000000000005e-141 < b Initial program 20.2%
lift-/.f64N/A
clear-numN/A
lift-*.f64N/A
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f64N/A
lower-/.f6420.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6420.1
Applied rewrites20.1%
Taylor expanded in a around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6486.1
Applied rewrites86.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e-38)
(- (/ c b) (/ b a))
(if (<= b 5.4e-141)
(/ (+ (- b) (sqrt (* -4.0 (* c a)))) (* 2.0 a))
(/ (- c) b))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e-38) {
tmp = (c / b) - (b / a);
} else if (b <= 5.4e-141) {
tmp = (-b + sqrt((-4.0 * (c * a)))) / (2.0 * 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 <= (-1.6d-38)) then
tmp = (c / b) - (b / a)
else if (b <= 5.4d-141) then
tmp = (-b + sqrt(((-4.0d0) * (c * a)))) / (2.0d0 * 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 <= -1.6e-38) {
tmp = (c / b) - (b / a);
} else if (b <= 5.4e-141) {
tmp = (-b + Math.sqrt((-4.0 * (c * a)))) / (2.0 * a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.6e-38: tmp = (c / b) - (b / a) elif b <= 5.4e-141: tmp = (-b + math.sqrt((-4.0 * (c * a)))) / (2.0 * a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.6e-38) tmp = Float64(Float64(c / b) - Float64(b / a)); elseif (b <= 5.4e-141) tmp = Float64(Float64(Float64(-b) + sqrt(Float64(-4.0 * Float64(c * a)))) / Float64(2.0 * a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.6e-38) tmp = (c / b) - (b / a); elseif (b <= 5.4e-141) tmp = (-b + sqrt((-4.0 * (c * a)))) / (2.0 * a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.6e-38], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 5.4e-141], N[(N[((-b) + N[Sqrt[N[(-4.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{-38}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{elif}\;b \leq 5.4 \cdot 10^{-141}:\\
\;\;\;\;\frac{\left(-b\right) + \sqrt{-4 \cdot \left(c \cdot a\right)}}{2 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -1.59999999999999989e-38Initial program 69.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
associate-*l/N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6492.7
Applied rewrites92.7%
Applied rewrites92.7%
if -1.59999999999999989e-38 < b < 5.4000000000000005e-141Initial program 77.5%
Taylor expanded in a around inf
lower-*.f64N/A
*-commutativeN/A
lower-*.f6470.8
Applied rewrites70.8%
if 5.4000000000000005e-141 < b Initial program 20.2%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6485.2
Applied rewrites85.2%
(FPCore (a b c) :precision binary64 (if (<= b -5e-311) (- (/ c b) (/ b a)) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-311) {
tmp = (c / b) - (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-311)) then
tmp = (c / b) - (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-311) {
tmp = (c / b) - (b / a);
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-311: tmp = (c / b) - (b / a) else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-311) tmp = Float64(Float64(c / b) - Float64(b / a)); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-311) tmp = (c / b) - (b / a); else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-311], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-311}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < -5.00000000000023e-311Initial program 72.7%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
associate-*l/N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6466.3
Applied rewrites66.3%
Applied rewrites66.4%
if -5.00000000000023e-311 < b Initial program 32.4%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6468.4
Applied rewrites68.4%
(FPCore (a b c) :precision binary64 (if (<= b 2.9e-273) (/ (- b) a) (/ (- c) b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 2.9e-273) {
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 <= 2.9d-273) 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 <= 2.9e-273) {
tmp = -b / a;
} else {
tmp = -c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 2.9e-273: tmp = -b / a else: tmp = -c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 2.9e-273) tmp = Float64(Float64(-b) / a); else tmp = Float64(Float64(-c) / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 2.9e-273) tmp = -b / a; else tmp = -c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 2.9e-273], N[((-b) / a), $MachinePrecision], N[((-c) / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 2.9 \cdot 10^{-273}:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-c}{b}\\
\end{array}
\end{array}
if b < 2.89999999999999986e-273Initial program 72.9%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6462.2
Applied rewrites62.2%
if 2.89999999999999986e-273 < b Initial program 29.8%
Taylor expanded in a around 0
associate-*r/N/A
lower-/.f64N/A
mul-1-negN/A
lower-neg.f6472.4
Applied rewrites72.4%
(FPCore (a b c) :precision binary64 (if (<= b 72.0) (/ (- b) a) (/ c b)))
double code(double a, double b, double c) {
double tmp;
if (b <= 72.0) {
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 <= 72.0d0) 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 <= 72.0) {
tmp = -b / a;
} else {
tmp = c / b;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 72.0: tmp = -b / a else: tmp = c / b return tmp
function code(a, b, c) tmp = 0.0 if (b <= 72.0) tmp = Float64(Float64(-b) / a); else tmp = Float64(c / b); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 72.0) tmp = -b / a; else tmp = c / b; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 72.0], N[((-b) / a), $MachinePrecision], N[(c / b), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 72:\\
\;\;\;\;\frac{-b}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b}\\
\end{array}
\end{array}
if b < 72Initial program 67.6%
Taylor expanded in b around -inf
associate-*r/N/A
mul-1-negN/A
lower-/.f64N/A
lower-neg.f6445.9
Applied rewrites45.9%
if 72 < b Initial program 15.7%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
associate-*l/N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f642.6
Applied rewrites2.6%
Taylor expanded in a around inf
Applied rewrites30.1%
(FPCore (a b c) :precision binary64 (/ c b))
double code(double a, double b, double c) {
return 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 = c / b
end function
public static double code(double a, double b, double c) {
return c / b;
}
def code(a, b, c): return c / b
function code(a, b, c) return Float64(c / b) end
function tmp = code(a, b, c) tmp = c / b; end
code[a_, b_, c_] := N[(c / b), $MachinePrecision]
\begin{array}{l}
\\
\frac{c}{b}
\end{array}
Initial program 51.0%
Taylor expanded in b around -inf
mul-1-negN/A
distribute-rgt-inN/A
distribute-neg-inN/A
mul-1-negN/A
distribute-lft-neg-outN/A
remove-double-negN/A
associate-*l/N/A
*-lft-identityN/A
lower-fma.f64N/A
unpow2N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f64N/A
distribute-frac-negN/A
lower-/.f64N/A
lower-neg.f6431.9
Applied rewrites31.9%
Taylor expanded in a around inf
Applied rewrites11.7%
herbie shell --seed 2024313
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))