
(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 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(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 -2.5e-41)
(/ c (- b))
(if (<= b 1e+96)
(/ (- (- 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 <= -2.5e-41) {
tmp = c / -b;
} else if (b <= 1e+96) {
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 <= (-2.5d-41)) then
tmp = c / -b
else if (b <= 1d+96) 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 <= -2.5e-41) {
tmp = c / -b;
} else if (b <= 1e+96) {
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 <= -2.5e-41: tmp = c / -b elif b <= 1e+96: 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 <= -2.5e-41) tmp = Float64(c / Float64(-b)); elseif (b <= 1e+96) 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 <= -2.5e-41) tmp = c / -b; elseif (b <= 1e+96) 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, -2.5e-41], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 1e+96], 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 -2.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 10^{+96}:\\
\;\;\;\;\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 < -2.4999999999999998e-41Initial program 13.5%
div-sub12.0%
sub-neg12.0%
neg-mul-112.0%
*-commutative12.0%
associate-/l*9.9%
distribute-neg-frac9.9%
neg-mul-19.9%
*-commutative9.9%
associate-/l*12.0%
distribute-rgt-out13.5%
associate-/r*13.5%
metadata-eval13.5%
sub-neg13.5%
+-commutative13.5%
Simplified13.5%
Taylor expanded in b around -inf 92.9%
mul-1-neg92.9%
distribute-neg-frac292.9%
Simplified92.9%
if -2.4999999999999998e-41 < b < 1.00000000000000005e96Initial program 80.3%
if 1.00000000000000005e96 < b Initial program 54.1%
div-sub54.1%
sub-neg54.1%
neg-mul-154.1%
*-commutative54.1%
associate-/l*54.0%
distribute-neg-frac54.0%
neg-mul-154.0%
*-commutative54.0%
associate-/l*54.0%
distribute-rgt-out54.0%
associate-/r*54.0%
metadata-eval54.0%
sub-neg54.0%
+-commutative54.0%
Simplified54.0%
Taylor expanded in a around 0 98.3%
+-commutative98.3%
mul-1-neg98.3%
unsub-neg98.3%
Simplified98.3%
Final simplification88.8%
(FPCore (a b c)
:precision binary64
(if (<= b -5.2e-92)
(/ c (- b))
(if (<= b 4.8e-82)
(* (/ -0.5 a) (+ b (sqrt (* c (* a -4.0)))))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-92) {
tmp = c / -b;
} else if (b <= 4.8e-82) {
tmp = (-0.5 / a) * (b + sqrt((c * (a * -4.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-92)) then
tmp = c / -b
else if (b <= 4.8d-82) then
tmp = ((-0.5d0) / a) * (b + sqrt((c * (a * (-4.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-92) {
tmp = c / -b;
} else if (b <= 4.8e-82) {
tmp = (-0.5 / a) * (b + Math.sqrt((c * (a * -4.0))));
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-92: tmp = c / -b elif b <= 4.8e-82: tmp = (-0.5 / a) * (b + math.sqrt((c * (a * -4.0)))) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-92) tmp = Float64(c / Float64(-b)); elseif (b <= 4.8e-82) tmp = Float64(Float64(-0.5 / a) * Float64(b + sqrt(Float64(c * Float64(a * -4.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-92) tmp = c / -b; elseif (b <= 4.8e-82) tmp = (-0.5 / a) * (b + sqrt((c * (a * -4.0)))); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-92], N[(c / (-b)), $MachinePrecision], If[LessEqual[b, 4.8e-82], N[(N[(-0.5 / a), $MachinePrecision] * N[(b + N[Sqrt[N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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^{-92}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{elif}\;b \leq 4.8 \cdot 10^{-82}:\\
\;\;\;\;\frac{-0.5}{a} \cdot \left(b + \sqrt{c \cdot \left(a \cdot -4\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.2e-92Initial program 17.2%
div-sub15.8%
sub-neg15.8%
neg-mul-115.8%
*-commutative15.8%
associate-/l*13.9%
distribute-neg-frac13.9%
neg-mul-113.9%
*-commutative13.9%
associate-/l*15.8%
distribute-rgt-out17.2%
associate-/r*17.2%
metadata-eval17.2%
sub-neg17.2%
+-commutative17.2%
Simplified17.3%
Taylor expanded in b around -inf 89.3%
mul-1-neg89.3%
distribute-neg-frac289.3%
Simplified89.3%
if -5.2e-92 < b < 4.80000000000000017e-82Initial program 83.8%
div-sub83.9%
sub-neg83.9%
neg-mul-183.9%
*-commutative83.9%
associate-/l*83.9%
distribute-neg-frac83.9%
neg-mul-183.9%
*-commutative83.9%
associate-/l*83.6%
distribute-rgt-out83.6%
associate-/r*83.6%
metadata-eval83.6%
sub-neg83.6%
+-commutative83.6%
Simplified83.6%
Taylor expanded in a around inf 78.9%
associate-*r*78.9%
Simplified78.9%
if 4.80000000000000017e-82 < b Initial program 64.1%
div-sub64.1%
sub-neg64.1%
neg-mul-164.1%
*-commutative64.1%
associate-/l*64.0%
distribute-neg-frac64.0%
neg-mul-164.0%
*-commutative64.0%
associate-/l*63.9%
distribute-rgt-out63.9%
associate-/r*63.9%
metadata-eval63.9%
sub-neg63.9%
+-commutative63.9%
Simplified63.9%
Taylor expanded in a around 0 86.3%
+-commutative86.3%
mul-1-neg86.3%
unsub-neg86.3%
Simplified86.3%
Final simplification85.6%
(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 28.7%
div-sub27.5%
sub-neg27.5%
neg-mul-127.5%
*-commutative27.5%
associate-/l*26.0%
distribute-neg-frac26.0%
neg-mul-126.0%
*-commutative26.0%
associate-/l*27.4%
distribute-rgt-out28.6%
associate-/r*28.6%
metadata-eval28.6%
sub-neg28.6%
+-commutative28.6%
Simplified28.6%
Taylor expanded in b around -inf 73.9%
mul-1-neg73.9%
distribute-neg-frac273.9%
Simplified73.9%
if -4.999999999999985e-310 < b Initial program 72.3%
div-sub72.3%
sub-neg72.3%
neg-mul-172.3%
*-commutative72.3%
associate-/l*72.3%
distribute-neg-frac72.3%
neg-mul-172.3%
*-commutative72.3%
associate-/l*72.2%
distribute-rgt-out72.2%
associate-/r*72.2%
metadata-eval72.2%
sub-neg72.2%
+-commutative72.2%
Simplified72.2%
Taylor expanded in a around 0 64.6%
+-commutative64.6%
mul-1-neg64.6%
unsub-neg64.6%
Simplified64.6%
Final simplification69.3%
(FPCore (a b c) :precision binary64 (if (<= b -5e-310) (/ c (- b)) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5e-310) {
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 <= (-5d-310)) 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 <= -5e-310) {
tmp = c / -b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5e-310: tmp = c / -b else: tmp = -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(-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 = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5e-310], N[(c / (-b)), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c}{-b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -4.999999999999985e-310Initial program 28.7%
div-sub27.5%
sub-neg27.5%
neg-mul-127.5%
*-commutative27.5%
associate-/l*26.0%
distribute-neg-frac26.0%
neg-mul-126.0%
*-commutative26.0%
associate-/l*27.4%
distribute-rgt-out28.6%
associate-/r*28.6%
metadata-eval28.6%
sub-neg28.6%
+-commutative28.6%
Simplified28.6%
Taylor expanded in b around -inf 73.9%
mul-1-neg73.9%
distribute-neg-frac273.9%
Simplified73.9%
if -4.999999999999985e-310 < b Initial program 72.3%
div-sub72.3%
sub-neg72.3%
neg-mul-172.3%
*-commutative72.3%
associate-/l*72.3%
distribute-neg-frac72.3%
neg-mul-172.3%
*-commutative72.3%
associate-/l*72.2%
distribute-rgt-out72.2%
associate-/r*72.2%
metadata-eval72.2%
sub-neg72.2%
+-commutative72.2%
Simplified72.2%
Taylor expanded in a around 0 63.6%
associate-*r/63.6%
mul-1-neg63.6%
Simplified63.6%
Final simplification68.8%
(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.0%
div-sub49.4%
sub-neg49.4%
neg-mul-149.4%
*-commutative49.4%
associate-/l*48.6%
distribute-neg-frac48.6%
neg-mul-148.6%
*-commutative48.6%
associate-/l*49.3%
distribute-rgt-out49.9%
associate-/r*49.9%
metadata-eval49.9%
sub-neg49.9%
+-commutative49.9%
Simplified49.9%
Taylor expanded in b around -inf 39.0%
mul-1-neg39.0%
distribute-neg-frac239.0%
Simplified39.0%
Final simplification39.0%
(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 / 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 50.0%
div-sub49.4%
sub-neg49.4%
neg-mul-149.4%
*-commutative49.4%
associate-/l*48.6%
distribute-neg-frac48.6%
neg-mul-148.6%
*-commutative48.6%
associate-/l*49.3%
distribute-rgt-out49.9%
associate-/r*49.9%
metadata-eval49.9%
sub-neg49.9%
+-commutative49.9%
Simplified49.9%
Applied egg-rr31.9%
Taylor expanded in b around -inf 2.5%
Final simplification2.5%
(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.0%
div-sub49.4%
sub-neg49.4%
neg-mul-149.4%
*-commutative49.4%
associate-/l*48.6%
distribute-neg-frac48.6%
neg-mul-148.6%
*-commutative48.6%
associate-/l*49.3%
distribute-rgt-out49.9%
associate-/r*49.9%
metadata-eval49.9%
sub-neg49.9%
+-commutative49.9%
Simplified49.9%
Applied egg-rr31.9%
Taylor expanded in a around 0 12.1%
Final simplification12.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 2024044
(FPCore (a b c)
:name "The quadratic formula (r2)"
:precision binary64
:herbie-target
(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)))