
(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 8 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.5e+168)
(/ b (- a))
(if (<= b 1.2e-103)
(/ (- (sqrt (fma b b (* a (* c -4.0)))) b) (* a 2.0))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.5e+168) {
tmp = b / -a;
} else if (b <= 1.2e-103) {
tmp = (sqrt(fma(b, b, (a * (c * -4.0)))) - b) / (a * 2.0);
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -2.5e+168) tmp = Float64(b / Float64(-a)); elseif (b <= 1.2e-103) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -4.0)))) - b) / Float64(a * 2.0)); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -2.5e+168], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 1.2e-103], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.5 \cdot 10^{+168}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 1.2 \cdot 10^{-103}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.49999999999999983e168Initial program 42.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.f64100.0
Applied rewrites100.0%
if -2.49999999999999983e168 < b < 1.2000000000000001e-103Initial program 87.6%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval87.8
Applied rewrites87.8%
if 1.2000000000000001e-103 < b Initial program 21.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
Final simplification89.1%
(FPCore (a b c)
:precision binary64
(if (<= b -1.9e+115)
(/ b (- a))
(if (<= b 4.9e-107)
(* (- (sqrt (fma b b (* a (* c -4.0)))) b) (/ 0.5 a))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e+115) {
tmp = b / -a;
} else if (b <= 4.9e-107) {
tmp = (sqrt(fma(b, b, (a * (c * -4.0)))) - b) * (0.5 / a);
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.9e+115) tmp = Float64(b / Float64(-a)); elseif (b <= 4.9e-107) tmp = Float64(Float64(sqrt(fma(b, b, Float64(a * Float64(c * -4.0)))) - b) * Float64(0.5 / a)); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.9e+115], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 4.9e-107], N[(N[(N[Sqrt[N[(b * b + N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+115}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 4.9 \cdot 10^{-107}:\\
\;\;\;\;\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -4\right)\right)} - b\right) \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.9e115Initial program 57.7%
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.f64100.0
Applied rewrites100.0%
if -1.9e115 < b < 4.8999999999999998e-107Initial program 85.8%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval86.0
Applied rewrites86.0%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6485.8
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6485.8
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6485.6
Applied rewrites85.6%
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
lower-*.f6485.8
Applied rewrites85.8%
if 4.8999999999999998e-107 < b Initial program 21.9%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6486.1
Applied rewrites86.1%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -1.9e+115)
(/ b (- a))
(if (<= b 6.5e-126)
(* (/ -0.5 a) (- b (sqrt (fma c (* a -4.0) (* b b)))))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.9e+115) {
tmp = b / -a;
} else if (b <= 6.5e-126) {
tmp = (-0.5 / a) * (b - sqrt(fma(c, (a * -4.0), (b * b))));
} else {
tmp = -(c / b);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.9e+115) tmp = Float64(b / Float64(-a)); elseif (b <= 6.5e-126) tmp = Float64(Float64(-0.5 / a) * Float64(b - sqrt(fma(c, Float64(a * -4.0), Float64(b * b))))); else tmp = Float64(-Float64(c / b)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.9e+115], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.5e-126], 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[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.9 \cdot 10^{+115}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6.5 \cdot 10^{-126}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(c, a \cdot -4, b \cdot b\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -1.9e115Initial program 57.7%
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.f64100.0
Applied rewrites100.0%
if -1.9e115 < b < 6.50000000000000014e-126Initial program 87.2%
Applied rewrites87.0%
if 6.50000000000000014e-126 < b Initial program 23.1%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification89.0%
(FPCore (a b c)
:precision binary64
(if (<= b -2.25e-41)
(/ b (- a))
(if (<= b 6.6e-127)
(/ (- (sqrt (* a (* c -4.0))) b) (* a 2.0))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.25e-41) {
tmp = b / -a;
} else if (b <= 6.6e-127) {
tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} 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.25d-41)) then
tmp = b / -a
else if (b <= 6.6d-127) then
tmp = (sqrt((a * (c * (-4.0d0)))) - b) / (a * 2.0d0)
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.25e-41) {
tmp = b / -a;
} else if (b <= 6.6e-127) {
tmp = (Math.sqrt((a * (c * -4.0))) - b) / (a * 2.0);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.25e-41: tmp = b / -a elif b <= 6.6e-127: tmp = (math.sqrt((a * (c * -4.0))) - b) / (a * 2.0) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.25e-41) tmp = Float64(b / Float64(-a)); elseif (b <= 6.6e-127) tmp = Float64(Float64(sqrt(Float64(a * Float64(c * -4.0))) - b) / Float64(a * 2.0)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.25e-41) tmp = b / -a; elseif (b <= 6.6e-127) tmp = (sqrt((a * (c * -4.0))) - b) / (a * 2.0); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.25e-41], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.6e-127], N[(N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-41}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-127}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(c \cdot -4\right)} - b}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.25e-41Initial program 72.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.f6495.7
Applied rewrites95.7%
if -2.25e-41 < b < 6.59999999999999961e-127Initial program 82.0%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.3
Applied rewrites73.3%
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6473.3
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites73.3%
if 6.59999999999999961e-127 < b Initial program 23.1%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification85.2%
(FPCore (a b c)
:precision binary64
(if (<= b -2.25e-41)
(/ b (- a))
(if (<= b 6.6e-127)
(* (/ 0.5 a) (- (sqrt (* a (* c -4.0))) b))
(- (/ c b)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2.25e-41) {
tmp = b / -a;
} else if (b <= 6.6e-127) {
tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b);
} 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.25d-41)) then
tmp = b / -a
else if (b <= 6.6d-127) then
tmp = (0.5d0 / a) * (sqrt((a * (c * (-4.0d0)))) - b)
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.25e-41) {
tmp = b / -a;
} else if (b <= 6.6e-127) {
tmp = (0.5 / a) * (Math.sqrt((a * (c * -4.0))) - b);
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2.25e-41: tmp = b / -a elif b <= 6.6e-127: tmp = (0.5 / a) * (math.sqrt((a * (c * -4.0))) - b) else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2.25e-41) tmp = Float64(b / Float64(-a)); elseif (b <= 6.6e-127) tmp = Float64(Float64(0.5 / a) * Float64(sqrt(Float64(a * Float64(c * -4.0))) - b)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -2.25e-41) tmp = b / -a; elseif (b <= 6.6e-127) tmp = (0.5 / a) * (sqrt((a * (c * -4.0))) - b); else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2.25e-41], N[(b / (-a)), $MachinePrecision], If[LessEqual[b, 6.6e-127], N[(N[(0.5 / a), $MachinePrecision] * N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], (-N[(c / b), $MachinePrecision])]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -2.25 \cdot 10^{-41}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{elif}\;b \leq 6.6 \cdot 10^{-127}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(\sqrt{a \cdot \left(c \cdot -4\right)} - b\right)\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < -2.25e-41Initial program 72.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.f6495.7
Applied rewrites95.7%
if -2.25e-41 < b < 6.59999999999999961e-127Initial program 82.0%
Taylor expanded in b around 0
*-commutativeN/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f6473.3
Applied rewrites73.3%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lift-/.f6473.1
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6473.1
Applied rewrites73.1%
if 6.59999999999999961e-127 < b Initial program 23.1%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6484.7
Applied rewrites84.7%
Final simplification85.2%
(FPCore (a b c) :precision binary64 (if (<= b 1.32e-298) (/ b (- a)) (- (/ c b))))
double code(double a, double b, double c) {
double tmp;
if (b <= 1.32e-298) {
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 <= 1.32d-298) 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 <= 1.32e-298) {
tmp = b / -a;
} else {
tmp = -(c / b);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= 1.32e-298: tmp = b / -a else: tmp = -(c / b) return tmp
function code(a, b, c) tmp = 0.0 if (b <= 1.32e-298) tmp = Float64(b / Float64(-a)); else tmp = Float64(-Float64(c / b)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= 1.32e-298) tmp = b / -a; else tmp = -(c / b); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, 1.32e-298], N[(b / (-a)), $MachinePrecision], (-N[(c / b), $MachinePrecision])]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.32 \cdot 10^{-298}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\
\end{array}
\end{array}
if b < 1.3200000000000001e-298Initial program 78.0%
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.f6468.7
Applied rewrites68.7%
if 1.3200000000000001e-298 < b Initial program 32.8%
Taylor expanded in b around inf
mul-1-negN/A
distribute-neg-frac2N/A
lower-/.f64N/A
lower-neg.f6470.6
Applied rewrites70.6%
Final simplification69.6%
(FPCore (a b c) :precision binary64 (if (<= b -1e-309) (/ b (- a)) 0.0))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = b / -a;
} else {
tmp = 0.0;
}
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 <= (-1d-309)) then
tmp = b / -a
else
tmp = 0.0d0
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-309) {
tmp = b / -a;
} else {
tmp = 0.0;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-309: tmp = b / -a else: tmp = 0.0 return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-309) tmp = Float64(b / Float64(-a)); else tmp = 0.0; end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-309) tmp = b / -a; else tmp = 0.0; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-309], N[(b / (-a)), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{b}{-a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b < -1.000000000000002e-309Initial program 78.0%
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.f6470.8
Applied rewrites70.8%
if -1.000000000000002e-309 < b Initial program 34.1%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval34.2
Applied rewrites34.2%
lift-/.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
metadata-evalN/A
lower-/.f6434.2
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6434.2
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6434.1
Applied rewrites34.1%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
lift-neg.f64N/A
distribute-lft-inN/A
lift-/.f64N/A
metadata-evalN/A
associate-/r*N/A
lift-*.f64N/A
lower-fma.f64N/A
Applied rewrites30.3%
Taylor expanded in a around 0
distribute-rgt-outN/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt19.2
Applied rewrites19.2%
(FPCore (a b c) :precision binary64 0.0)
double code(double a, double b, double c) {
return 0.0;
}
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
end function
public static double code(double a, double b, double c) {
return 0.0;
}
def code(a, b, c): return 0.0
function code(a, b, c) return 0.0 end
function tmp = code(a, b, c) tmp = 0.0; end
code[a_, b_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 55.7%
lift--.f64N/A
sub-negN/A
lift-*.f64N/A
lower-fma.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
associate-*l*N/A
lower-*.f64N/A
lower-*.f64N/A
metadata-eval55.8
Applied rewrites55.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-/.f6455.7
lift-+.f64N/A
+-commutativeN/A
lift-neg.f64N/A
unsub-negN/A
lower--.f6455.7
lift-fma.f64N/A
lift-*.f64N/A
+-commutativeN/A
lift-*.f64N/A
lower-fma.f6455.6
Applied rewrites55.6%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
lift-fma.f64N/A
lift-*.f64N/A
associate-*r*N/A
lift-*.f64N/A
*-commutativeN/A
lift-fma.f64N/A
lift-neg.f64N/A
distribute-lft-inN/A
lift-/.f64N/A
metadata-evalN/A
associate-/r*N/A
lift-*.f64N/A
lower-fma.f64N/A
Applied rewrites53.7%
Taylor expanded in a around 0
distribute-rgt-outN/A
metadata-evalN/A
associate-*l/N/A
mul0-rgt11.0
Applied rewrites11.0%
herbie shell --seed 2024232
(FPCore (a b c)
:name "Quadratic roots, full range"
:precision binary64
(/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))