
(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 6 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 -5.2e-104)
(/ c (- b))
(if (<= b 4.4e+73)
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* c a))))) (* a 2.0))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-104) {
tmp = c / -b;
} else if (b <= 4.4e+73) {
tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (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 <= (-5.2d-104)) then
tmp = c / -b
else if (b <= 4.4d+73) then
tmp = (-b - sqrt(((b * b) - (4.0d0 * (c * a))))) / (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 <= -5.2e-104) {
tmp = c / -b;
} else if (b <= 4.4e+73) {
tmp = (-b - Math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-104: tmp = c / -b elif b <= 4.4e+73: tmp = (-b - math.sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-104) tmp = Float64(c / Float64(-b)); elseif (b <= 4.4e+73) tmp = Float64(Float64(Float64(-b) - sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(c * a))))) / 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 <= -5.2e-104) tmp = c / -b; elseif (b <= 4.4e+73) tmp = (-b - sqrt(((b * b) - (4.0 * (c * a))))) / (a * 2.0); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-104], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 4.4e+73], N[(N[((-b) - N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(c * a), $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 -5.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 4.4 \cdot 10^{+73}:\\
\;\;\;\;\frac{\left(-b\right) - \sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)}}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.20000000000000005e-104Initial program 15.8%
div-sub14.3%
sub-neg14.3%
neg-mul-114.3%
*-commutative14.3%
associate-/l*13.2%
distribute-neg-frac13.2%
neg-mul-113.2%
*-commutative13.2%
associate-/l*14.3%
distribute-rgt-out15.8%
associate-/r*15.8%
metadata-eval15.8%
sub-neg15.8%
+-commutative15.8%
Simplified15.8%
Taylor expanded in b around -inf 88.6%
mul-1-neg88.6%
distribute-neg-frac288.6%
Simplified88.6%
if -5.20000000000000005e-104 < b < 4.4e73Initial program 80.4%
if 4.4e73 < b Initial program 60.9%
div-sub60.9%
sub-neg60.9%
neg-mul-160.9%
*-commutative60.9%
associate-/l*60.9%
distribute-neg-frac60.9%
neg-mul-160.9%
*-commutative60.9%
associate-/l*60.8%
distribute-rgt-out60.8%
associate-/r*60.8%
metadata-eval60.8%
sub-neg60.8%
+-commutative60.8%
Simplified60.9%
Taylor expanded in c around 0 94.7%
+-commutative94.7%
mul-1-neg94.7%
unsub-neg94.7%
Simplified94.7%
Final simplification87.2%
(FPCore (a b c)
:precision binary64
(if (<= b -9e-104)
(/ c (- b))
(if (<= b 0.102)
(* -0.5 (/ (+ b (sqrt (* a (* c -4.0)))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -9e-104) {
tmp = c / -b;
} else if (b <= 0.102) {
tmp = -0.5 * ((b + sqrt((a * (c * -4.0)))) / a);
} 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 <= (-9d-104)) then
tmp = c / -b
else if (b <= 0.102d0) then
tmp = (-0.5d0) * ((b + sqrt((a * (c * (-4.0d0))))) / a)
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 <= -9e-104) {
tmp = c / -b;
} else if (b <= 0.102) {
tmp = -0.5 * ((b + Math.sqrt((a * (c * -4.0)))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -9e-104: tmp = c / -b elif b <= 0.102: tmp = -0.5 * ((b + math.sqrt((a * (c * -4.0)))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -9e-104) tmp = Float64(c / Float64(-b)); elseif (b <= 0.102) tmp = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(a * Float64(c * -4.0)))) / a)); 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 <= -9e-104) tmp = c / -b; elseif (b <= 0.102) tmp = -0.5 * ((b + sqrt((a * (c * -4.0)))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -9e-104], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 0.102], N[(-0.5 * N[(N[(b + N[Sqrt[N[(a * N[(c * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -9 \cdot 10^{-104}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 0.102:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{a \cdot \left(c \cdot -4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -8.9999999999999995e-104Initial program 15.8%
div-sub14.3%
sub-neg14.3%
neg-mul-114.3%
*-commutative14.3%
associate-/l*13.2%
distribute-neg-frac13.2%
neg-mul-113.2%
*-commutative13.2%
associate-/l*14.3%
distribute-rgt-out15.8%
associate-/r*15.8%
metadata-eval15.8%
sub-neg15.8%
+-commutative15.8%
Simplified15.8%
Taylor expanded in b around -inf 88.6%
mul-1-neg88.6%
distribute-neg-frac288.6%
Simplified88.6%
if -8.9999999999999995e-104 < b < 0.101999999999999993Initial program 78.6%
*-commutative78.6%
*-commutative78.6%
sqr-neg78.6%
*-commutative78.6%
sqr-neg78.6%
*-commutative78.6%
associate-*r*78.6%
Simplified78.6%
Taylor expanded in b around 0 73.6%
associate-*r*73.6%
*-commutative73.6%
Simplified73.6%
add-cbrt-cube61.7%
pow1/358.0%
pow358.0%
sqrt-pow258.0%
associate-*l*58.0%
*-commutative58.0%
metadata-eval58.0%
Applied egg-rr58.0%
unpow1/361.7%
Simplified61.7%
frac-2neg61.7%
distribute-frac-neg261.7%
neg-sub061.7%
add-sqr-sqrt37.4%
sqrt-unprod60.4%
sqr-neg60.4%
sqrt-unprod22.9%
add-sqr-sqrt60.8%
associate-+l-60.8%
neg-sub060.8%
add-sqr-sqrt38.0%
sqrt-unprod61.6%
sqr-neg61.6%
sqrt-unprod24.2%
add-sqr-sqrt61.7%
pow1/358.0%
pow-pow73.6%
metadata-eval73.6%
pow1/273.6%
Applied egg-rr73.6%
distribute-neg-frac73.6%
neg-mul-173.6%
*-commutative73.6%
times-frac73.6%
metadata-eval73.6%
Simplified73.6%
if 0.101999999999999993 < b Initial program 66.5%
div-sub66.5%
sub-neg66.5%
neg-mul-166.5%
*-commutative66.5%
associate-/l*66.5%
distribute-neg-frac66.5%
neg-mul-166.5%
*-commutative66.5%
associate-/l*66.4%
distribute-rgt-out66.4%
associate-/r*66.4%
metadata-eval66.4%
sub-neg66.4%
+-commutative66.4%
Simplified66.5%
Taylor expanded in c around 0 91.4%
+-commutative91.4%
mul-1-neg91.4%
unsub-neg91.4%
Simplified91.4%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ c (- b)) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
tmp = c / -b;
} 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 = c / -b
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 = c / -b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = c / -b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5e-310) tmp = Float64(c / Float64(-b)); 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 = c / -b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c / (-b)), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 33.3%
div-sub32.3%
sub-neg32.3%
neg-mul-132.3%
*-commutative32.3%
associate-/l*31.5%
distribute-neg-frac31.5%
neg-mul-131.5%
*-commutative31.5%
associate-/l*32.2%
distribute-rgt-out33.3%
associate-/r*33.3%
metadata-eval33.3%
sub-neg33.3%
+-commutative33.3%
Simplified33.3%
Taylor expanded in b around -inf 66.3%
mul-1-neg66.3%
distribute-neg-frac266.3%
Simplified66.3%
if -4.999999999999985e-310 < b Initial program 71.5%
div-sub71.6%
sub-neg71.6%
neg-mul-171.6%
*-commutative71.6%
associate-/l*71.5%
distribute-neg-frac71.5%
neg-mul-171.5%
*-commutative71.5%
associate-/l*71.4%
distribute-rgt-out71.4%
associate-/r*71.4%
metadata-eval71.4%
sub-neg71.4%
+-commutative71.4%
Simplified71.5%
Taylor expanded in c around 0 71.8%
+-commutative71.8%
mul-1-neg71.8%
unsub-neg71.8%
Simplified71.8%
(FPCore (a b c) :precision binary64 (if (<= b -1e-248) (/ c (- b)) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1e-248) {
tmp = c / -b;
} 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 <= (-1d-248)) then
tmp = c / -b
else
tmp = -b / a
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double tmp;
if (b <= -1e-248) {
tmp = c / -b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1e-248: tmp = c / -b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1e-248) tmp = Float64(c / Float64(-b)); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1e-248) tmp = c / -b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1e-248], N[(c / (-b)), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1 \cdot 10^{-248}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -9.9999999999999998e-249Initial program 29.7%
div-sub28.6%
sub-neg28.6%
neg-mul-128.6%
*-commutative28.6%
associate-/l*27.8%
distribute-neg-frac27.8%
neg-mul-127.8%
*-commutative27.8%
associate-/l*28.5%
distribute-rgt-out29.7%
associate-/r*29.7%
metadata-eval29.7%
sub-neg29.7%
+-commutative29.7%
Simplified29.7%
Taylor expanded in b around -inf 71.1%
mul-1-neg71.1%
distribute-neg-frac271.1%
Simplified71.1%
if -9.9999999999999998e-249 < b Initial program 72.2%
div-sub72.2%
sub-neg72.2%
neg-mul-172.2%
*-commutative72.2%
associate-/l*72.2%
distribute-neg-frac72.2%
neg-mul-172.2%
*-commutative72.2%
associate-/l*72.1%
distribute-rgt-out72.1%
associate-/r*72.1%
metadata-eval72.1%
sub-neg72.1%
+-commutative72.1%
Simplified72.2%
Taylor expanded in a around 0 66.2%
associate-*r/66.2%
mul-1-neg66.2%
Simplified66.2%
(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 / Float64(-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 50.6%
div-sub50.1%
sub-neg50.1%
neg-mul-150.1%
*-commutative50.1%
associate-/l*49.6%
distribute-neg-frac49.6%
neg-mul-149.6%
*-commutative49.6%
associate-/l*50.0%
distribute-rgt-out50.6%
associate-/r*50.6%
metadata-eval50.6%
sub-neg50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in b around -inf 37.4%
mul-1-neg37.4%
distribute-neg-frac237.4%
Simplified37.4%
(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 50.6%
div-sub50.1%
sub-neg50.1%
neg-mul-150.1%
*-commutative50.1%
associate-/l*49.6%
distribute-neg-frac49.6%
neg-mul-149.6%
*-commutative49.6%
associate-/l*50.0%
distribute-rgt-out50.6%
associate-/r*50.6%
metadata-eval50.6%
sub-neg50.6%
+-commutative50.6%
Simplified50.6%
Taylor expanded in b around -inf 28.2%
*-commutative28.2%
associate-/l*31.0%
Simplified31.0%
associate-*r/28.2%
frac-2neg28.2%
add-sqr-sqrt27.1%
sqrt-unprod21.8%
sqr-neg21.8%
sqrt-prod1.4%
add-sqr-sqrt12.1%
Applied egg-rr12.1%
distribute-frac-neg12.1%
associate-*r/12.2%
distribute-rgt-neg-in12.2%
Simplified12.2%
Taylor expanded in a around 0 12.1%
(FPCore (a b c)
:precision binary64
(let* ((t_0 (sqrt (- (* b b) (* 4.0 (* a c))))))
(if (< b 0.0)
(/ c (* a (/ (+ (- b) t_0) (* 2.0 a))))
(/ (- (- b) t_0) (* 2.0 a)))))
double code(double a, double b, double c) {
double t_0 = sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.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) :: t_0
real(8) :: tmp
t_0 = sqrt(((b * b) - (4.0d0 * (a * c))))
if (b < 0.0d0) then
tmp = c / (a * ((-b + t_0) / (2.0d0 * a)))
else
tmp = (-b - t_0) / (2.0d0 * a)
end if
code = tmp
end function
public static double code(double a, double b, double c) {
double t_0 = Math.sqrt(((b * b) - (4.0 * (a * c))));
double tmp;
if (b < 0.0) {
tmp = c / (a * ((-b + t_0) / (2.0 * a)));
} else {
tmp = (-b - t_0) / (2.0 * a);
}
return tmp;
}
def code(a, b, c): t_0 = math.sqrt(((b * b) - (4.0 * (a * c)))) tmp = 0 if b < 0.0: tmp = c / (a * ((-b + t_0) / (2.0 * a))) else: tmp = (-b - t_0) / (2.0 * a) return tmp
function code(a, b, c) t_0 = sqrt(Float64(Float64(b * b) - Float64(4.0 * Float64(a * c)))) tmp = 0.0 if (b < 0.0) tmp = Float64(c / Float64(a * Float64(Float64(Float64(-b) + t_0) / Float64(2.0 * a)))); else tmp = Float64(Float64(Float64(-b) - t_0) / Float64(2.0 * a)); end return tmp end
function tmp_2 = code(a, b, c) t_0 = sqrt(((b * b) - (4.0 * (a * c)))); tmp = 0.0; if (b < 0.0) tmp = c / (a * ((-b + t_0) / (2.0 * a))); else tmp = (-b - t_0) / (2.0 * a); end tmp_2 = tmp; end
code[a_, b_, c_] := Block[{t$95$0 = N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(4.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Less[b, 0.0], N[(c / N[(a * N[(N[((-b) + t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-b) - t$95$0), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\\
\mathbf{if}\;b < 0:\\
\;\;\;\;\frac{c}{a \cdot \frac{\left(-b\right) + t\_0}{2 \cdot a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b\right) - t\_0}{2 \cdot a}\\
\end{array}
\end{array}
herbie shell --seed 2024100
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:alt
(if (< b 0.0) (/ c (* a (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))) (/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))
(/ (- (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) (* 2.0 a)))