
(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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 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(4.0 * Float64(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[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}
\end{array}
(FPCore (a b c)
:precision binary64
(if (<= b -1.6e+47)
0.0
(if (<= b 8.6e+32)
(- (* b (/ -0.5 a)) (* (sqrt (fma a (* c -4.0) (pow b 2.0))) (/ 0.5 a)))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.6e+47) {
tmp = 0.0;
} else if (b <= 8.6e+32) {
tmp = (b * (-0.5 / a)) - (sqrt(fma(a, (c * -4.0), pow(b, 2.0))) * (0.5 / a));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
function code(a, b, c) tmp = 0.0 if (b <= -1.6e+47) tmp = 0.0; elseif (b <= 8.6e+32) tmp = Float64(Float64(b * Float64(-0.5 / a)) - Float64(sqrt(fma(a, Float64(c * -4.0), (b ^ 2.0))) * Float64(0.5 / a))); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
code[a_, b_, c_] := If[LessEqual[b, -1.6e+47], 0.0, If[LessEqual[b, 8.6e+32], N[(N[(b * N[(-0.5 / a), $MachinePrecision]), $MachinePrecision] - N[(N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision] + N[Power[b, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[(0.5 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+47}:\\
\;\;\;\;0\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;b \cdot \frac{-0.5}{a} - \sqrt{\mathsf{fma}\left(a, c \cdot -4, {b}^{2}\right)} \cdot \frac{0.5}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.6e47Initial program 29.4%
div-sub24.9%
sub-neg24.9%
neg-mul-124.9%
*-commutative24.9%
associate-/l*18.0%
distribute-neg-frac18.0%
neg-mul-118.0%
*-commutative18.0%
associate-/l*24.9%
distribute-rgt-out29.4%
associate-/r*29.4%
metadata-eval29.4%
sub-neg29.4%
+-commutative29.4%
Simplified29.5%
add-sqr-sqrt20.0%
pow220.0%
pow1/220.0%
sqrt-pow120.0%
pow220.0%
metadata-eval20.0%
Applied egg-rr20.0%
Taylor expanded in b around -inf 47.1%
distribute-rgt-out47.1%
metadata-eval47.1%
mul0-rgt70.8%
Simplified70.8%
if -1.6e47 < b < 8.5999999999999994e32Initial program 83.7%
div-sub83.7%
sub-neg83.7%
neg-mul-183.7%
*-commutative83.7%
associate-/l*81.3%
distribute-neg-frac81.3%
neg-mul-181.3%
*-commutative81.3%
associate-/l*83.7%
distribute-rgt-out83.6%
associate-/r*83.6%
metadata-eval83.6%
sub-neg83.6%
+-commutative83.6%
Simplified83.6%
Applied egg-rr83.7%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification83.3%
(FPCore (a b c)
:precision binary64
(if (<= b -3e+136)
0.0
(if (<= b 8.6e+32)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -3e+136) {
tmp = 0.0;
} else if (b <= 8.6e+32) {
tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / 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 <= (-3d+136)) then
tmp = 0.0d0
else if (b <= 8.6d+32) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (a * c))))) / (a * 2.0d0)
else
tmp = (c / b) - (b / a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -3e+136) {
tmp = 0.0;
} else if (b <= 8.6e+32) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -3e+136: tmp = 0.0 elif b <= 8.6e+32: tmp = (-b - math.sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -3e+136) tmp = 0.0; elseif (b <= 8.6e+32) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c))))) / Float64(a * 2.0)); else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -3e+136) tmp = 0.0; elseif (b <= 8.6e+32) tmp = (-b - sqrt(((b * b) - (4.0 * (a * c))))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -3e+136], 0.0, If[LessEqual[b, 8.6e+32], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -3 \cdot 10^{+136}:\\
\;\;\;\;0\\
\mathbf{elif}\;b \leq 8.6 \cdot 10^{+32}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -2.99999999999999979e136Initial program 6.2%
div-sub5.6%
sub-neg5.6%
neg-mul-15.6%
*-commutative5.6%
associate-/l*5.6%
distribute-neg-frac5.6%
neg-mul-15.6%
*-commutative5.6%
associate-/l*5.6%
distribute-rgt-out6.2%
associate-/r*6.2%
metadata-eval6.2%
sub-neg6.2%
+-commutative6.2%
Simplified6.2%
add-sqr-sqrt4.0%
pow24.0%
pow1/24.0%
sqrt-pow14.0%
pow24.0%
metadata-eval4.0%
Applied egg-rr4.0%
Taylor expanded in b around -inf 42.8%
distribute-rgt-out42.8%
metadata-eval42.8%
mul0-rgt75.4%
Simplified75.4%
if -2.99999999999999979e136 < b < 8.5999999999999994e32Initial program 79.9%
if 8.5999999999999994e32 < b Initial program 62.1%
div-sub62.1%
sub-neg62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.1%
distribute-neg-frac62.1%
neg-mul-162.1%
*-commutative62.1%
associate-/l*62.0%
distribute-rgt-out62.0%
associate-/r*62.0%
metadata-eval62.0%
sub-neg62.0%
+-commutative62.0%
Simplified62.0%
Taylor expanded in a around 0 97.1%
+-commutative97.1%
mul-1-neg97.1%
unsub-neg97.1%
Simplified97.1%
Final simplification83.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) 0.0 (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = 0.0;
} else {
tmp = (c / b) - (b / 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.0d0
else
tmp = (c / b) - (b / 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.0;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = 0.0 else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = 0.0; else tmp = Float64(Float64(c / b) - Float64(b / a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = 0.0; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 0.0, N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 54.9%
div-sub52.6%
sub-neg52.6%
neg-mul-152.6%
*-commutative52.6%
associate-/l*46.6%
distribute-neg-frac46.6%
neg-mul-146.6%
*-commutative46.6%
associate-/l*52.5%
distribute-rgt-out54.9%
associate-/r*54.9%
metadata-eval54.9%
sub-neg54.9%
+-commutative54.9%
Simplified55.0%
add-sqr-sqrt43.2%
pow243.2%
pow1/243.2%
sqrt-pow143.2%
pow243.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in b around -inf 38.7%
distribute-rgt-out38.7%
metadata-eval38.7%
mul0-rgt51.5%
Simplified51.5%
if -4.999999999999985e-310 < b Initial program 71.9%
div-sub71.9%
sub-neg71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-neg-frac71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-rgt-out71.9%
associate-/r*71.9%
metadata-eval71.9%
sub-neg71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in a around 0 66.8%
+-commutative66.8%
mul-1-neg66.8%
unsub-neg66.8%
Simplified66.8%
Final simplification58.9%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) 0.0 (/ b (- a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = 0.0;
} else {
tmp = b / -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.0d0
else
tmp = b / -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.0;
} else {
tmp = b / -a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = 0.0 else: tmp = b / -a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = 0.0; else tmp = Float64(b / Float64(-a)); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5e-310) tmp = 0.0; else tmp = b / -a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], 0.0, N[(b / (-a)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{-a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 54.9%
div-sub52.6%
sub-neg52.6%
neg-mul-152.6%
*-commutative52.6%
associate-/l*46.6%
distribute-neg-frac46.6%
neg-mul-146.6%
*-commutative46.6%
associate-/l*52.5%
distribute-rgt-out54.9%
associate-/r*54.9%
metadata-eval54.9%
sub-neg54.9%
+-commutative54.9%
Simplified55.0%
add-sqr-sqrt43.2%
pow243.2%
pow1/243.2%
sqrt-pow143.2%
pow243.2%
metadata-eval43.2%
Applied egg-rr43.2%
Taylor expanded in b around -inf 38.7%
distribute-rgt-out38.7%
metadata-eval38.7%
mul0-rgt51.5%
Simplified51.5%
if -4.999999999999985e-310 < b Initial program 71.9%
div-sub71.9%
sub-neg71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-neg-frac71.9%
neg-mul-171.9%
*-commutative71.9%
associate-/l*71.9%
distribute-rgt-out71.9%
associate-/r*71.9%
metadata-eval71.9%
sub-neg71.9%
+-commutative71.9%
Simplified71.9%
Taylor expanded in a around 0 66.4%
associate-*r/66.4%
mul-1-neg66.4%
Simplified66.4%
Final simplification58.7%
(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 63.1%
div-sub61.9%
sub-neg61.9%
neg-mul-161.9%
*-commutative61.9%
associate-/l*58.8%
distribute-neg-frac58.8%
neg-mul-158.8%
*-commutative58.8%
associate-/l*61.8%
distribute-rgt-out63.1%
associate-/r*63.1%
metadata-eval63.1%
sub-neg63.1%
+-commutative63.1%
Simplified63.1%
add-sqr-sqrt56.9%
pow256.9%
pow1/256.9%
sqrt-pow156.9%
pow256.9%
metadata-eval56.9%
Applied egg-rr56.9%
Taylor expanded in b around -inf 21.3%
distribute-rgt-out21.3%
metadata-eval21.3%
mul0-rgt28.1%
Simplified28.1%
Final simplification28.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (fabs (/ b 2.0)))
(t_1 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_2
(if (== (copysign a c) a)
(* (sqrt (- t_0 t_1)) (sqrt (+ t_0 t_1)))
(hypot (/ b 2.0) t_1))))
(if (< b 0.0) (/ c (- t_2 (/ b 2.0))) (/ (+ (/ b 2.0) t_2) (- a)))))
double code(double a, double b, double c) {
double t_0 = fabs((b / 2.0));
double t_1 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp;
if (copysign(a, c) == a) {
tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1));
} else {
tmp = hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
public static double code(double a, double b, double c) {
double t_0 = Math.abs((b / 2.0));
double t_1 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp;
if (Math.copySign(a, c) == a) {
tmp = Math.sqrt((t_0 - t_1)) * Math.sqrt((t_0 + t_1));
} else {
tmp = Math.hypot((b / 2.0), t_1);
}
double t_2 = tmp;
double tmp_1;
if (b < 0.0) {
tmp_1 = c / (t_2 - (b / 2.0));
} else {
tmp_1 = ((b / 2.0) + t_2) / -a;
}
return tmp_1;
}
def code(a, b, c): t_0 = math.fabs((b / 2.0)) t_1 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp = 0 if math.copysign(a, c) == a: tmp = math.sqrt((t_0 - t_1)) * math.sqrt((t_0 + t_1)) else: tmp = math.hypot((b / 2.0), t_1) t_2 = tmp tmp_1 = 0 if b < 0.0: tmp_1 = c / (t_2 - (b / 2.0)) else: tmp_1 = ((b / 2.0) + t_2) / -a return tmp_1
function code(a, b, c) t_0 = abs(Float64(b / 2.0)) t_1 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp = 0.0 if (copysign(a, c) == a) tmp = Float64(sqrt(Float64(t_0 - t_1)) * sqrt(Float64(t_0 + t_1))); else tmp = hypot(Float64(b / 2.0), t_1); end t_2 = tmp tmp_1 = 0.0 if (b < 0.0) tmp_1 = Float64(c / Float64(t_2 - Float64(b / 2.0))); else tmp_1 = Float64(Float64(Float64(b / 2.0) + t_2) / Float64(-a)); end return tmp_1 end
function tmp_3 = code(a, b, c) t_0 = abs((b / 2.0)); t_1 = sqrt(abs(a)) * sqrt(abs(c)); tmp = 0.0; if ((sign(c) * abs(a)) == a) tmp = sqrt((t_0 - t_1)) * sqrt((t_0 + t_1)); else tmp = hypot((b / 2.0), t_1); end t_2 = tmp; tmp_2 = 0.0; if (b < 0.0) tmp_2 = c / (t_2 - (b / 2.0)); else tmp_2 = ((b / 2.0) + t_2) / -a; end tmp_3 = tmp_2; end
code[a_, b_, c_] := Block[{t$95$0 = N[Abs[N[(b / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], N[(N[Sqrt[N[(t$95$0 - t$95$1), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(b / 2.0), $MachinePrecision] ^ 2 + t$95$1 ^ 2], $MachinePrecision]]}, If[Less[b, 0.0], N[(c / N[(t$95$2 - N[(b / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / 2.0), $MachinePrecision] + t$95$2), $MachinePrecision] / (-a)), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|\frac{b}{2}\right|\\
t_1 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_2 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\sqrt{t\_0 - t\_1} \cdot \sqrt{t\_0 + t\_1}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(\frac{b}{2}, t\_1\right)\\
\end{array}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{t\_2 - \frac{b}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{2} + t\_2}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2024046
(FPCore (a b c)
:name "quadm (p42, negative)"
:precision binary64
:herbie-expected 10
:herbie-target
(if (< b 0.0) (/ c (- (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b 2.0))) (/ (+ (/ b 2.0) (if (== (copysign a c) a) (* (sqrt (- (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs (/ b 2.0)) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (hypot (/ b 2.0) (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))