
(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 -5.1e-30)
(/ (- c) b)
(if (<= b 5.5e+78)
(* -0.5 (/ (+ b (sqrt (- (* b b) (* a (* c 4.0))))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 5.5e+78) {
tmp = -0.5 * ((b + sqrt(((b * b) - (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 <= (-5.1d-30)) then
tmp = -c / b
else if (b <= 5.5d+78) then
tmp = (-0.5d0) * ((b + sqrt(((b * b) - (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 <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 5.5e+78) {
tmp = -0.5 * ((b + Math.sqrt(((b * b) - (a * (c * 4.0))))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-30: tmp = -c / b elif b <= 5.5e+78: tmp = -0.5 * ((b + math.sqrt(((b * b) - (a * (c * 4.0))))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-30) tmp = Float64(Float64(-c) / b); elseif (b <= 5.5e+78) tmp = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(Float64(b * b) - 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 <= -5.1e-30) tmp = -c / b; elseif (b <= 5.5e+78) tmp = -0.5 * ((b + sqrt(((b * b) - (a * (c * 4.0))))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-30], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 5.5e+78], N[(-0.5 * N[(N[(b + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(a * N[(c * 4.0), $MachinePrecision]), $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 -5.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 5.5 \cdot 10^{+78}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{b \cdot b - a \cdot \left(c \cdot 4\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.09999999999999972e-30Initial program 11.4%
Taylor expanded in b around -inf 91.9%
associate-*r/91.9%
neg-mul-191.9%
Simplified91.9%
if -5.09999999999999972e-30 < b < 5.4999999999999997e78Initial program 80.2%
Simplified80.2%
fma-udef80.2%
associate-*r*80.2%
metadata-eval80.2%
distribute-rgt-neg-in80.2%
*-commutative80.2%
+-commutative80.2%
sub-neg80.2%
*-commutative80.2%
associate-*l*80.2%
Applied egg-rr80.2%
if 5.4999999999999997e78 < b Initial program 59.4%
Taylor expanded in b around inf 96.8%
mul-1-neg96.8%
unsub-neg96.8%
Simplified96.8%
Final simplification88.2%
(FPCore (a b c)
:precision binary64
(if (<= b -5.1e-30)
(/ (- c) b)
(if (<= b 1.45e-44)
(* -0.5 (/ (+ b (sqrt (* (* c a) -4.0))) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 1.45e-44) {
tmp = -0.5 * ((b + sqrt(((c * a) * -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 <= (-5.1d-30)) then
tmp = -c / b
else if (b <= 1.45d-44) then
tmp = (-0.5d0) * ((b + sqrt(((c * a) * (-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 <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 1.45e-44) {
tmp = -0.5 * ((b + Math.sqrt(((c * a) * -4.0))) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-30: tmp = -c / b elif b <= 1.45e-44: tmp = -0.5 * ((b + math.sqrt(((c * a) * -4.0))) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-30) tmp = Float64(Float64(-c) / b); elseif (b <= 1.45e-44) tmp = Float64(-0.5 * Float64(Float64(b + sqrt(Float64(Float64(c * a) * -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 <= -5.1e-30) tmp = -c / b; elseif (b <= 1.45e-44) tmp = -0.5 * ((b + sqrt(((c * a) * -4.0))) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-30], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 1.45e-44], N[(-0.5 * N[(N[(b + N[Sqrt[N[(N[(c * a), $MachinePrecision] * -4.0), $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 -5.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 1.45 \cdot 10^{-44}:\\
\;\;\;\;-0.5 \cdot \frac{b + \sqrt{\left(c \cdot a\right) \cdot -4}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.09999999999999972e-30Initial program 11.4%
Taylor expanded in b around -inf 91.9%
associate-*r/91.9%
neg-mul-191.9%
Simplified91.9%
if -5.09999999999999972e-30 < b < 1.4500000000000001e-44Initial program 74.7%
Simplified74.7%
Taylor expanded in a around inf 68.2%
*-commutative68.2%
Simplified68.2%
if 1.4500000000000001e-44 < b Initial program 70.8%
Taylor expanded in b around inf 94.2%
mul-1-neg94.2%
unsub-neg94.2%
Simplified94.2%
Final simplification84.9%
(FPCore (a b c)
:precision binary64
(if (<= b -5.1e-30)
(/ (- c) b)
(if (<= b 3.9e-43)
(* -0.5 (/ (pow (* c (/ a -0.25)) 0.5) a))
(- (/ c b) (/ b a)))))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 3.9e-43) {
tmp = -0.5 * (pow((c * (a / -0.25)), 0.5) / 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 <= (-5.1d-30)) then
tmp = -c / b
else if (b <= 3.9d-43) then
tmp = (-0.5d0) * (((c * (a / (-0.25d0))) ** 0.5d0) / 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 <= -5.1e-30) {
tmp = -c / b;
} else if (b <= 3.9e-43) {
tmp = -0.5 * (Math.pow((c * (a / -0.25)), 0.5) / a);
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.1e-30: tmp = -c / b elif b <= 3.9e-43: tmp = -0.5 * (math.pow((c * (a / -0.25)), 0.5) / a) else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.1e-30) tmp = Float64(Float64(-c) / b); elseif (b <= 3.9e-43) tmp = Float64(-0.5 * Float64((Float64(c * Float64(a / -0.25)) ^ 0.5) / 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 <= -5.1e-30) tmp = -c / b; elseif (b <= 3.9e-43) tmp = -0.5 * (((c * (a / -0.25)) ^ 0.5) / a); else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.1e-30], N[((-c) / b), $MachinePrecision], If[LessEqual[b, 3.9e-43], N[(-0.5 * N[(N[Power[N[(c * N[(a / -0.25), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c / b), $MachinePrecision] - N[(b / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.1 \cdot 10^{-30}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{elif}\;b \leq 3.9 \cdot 10^{-43}:\\
\;\;\;\;-0.5 \cdot \frac{{\left(c \cdot \frac{a}{-0.25}\right)}^{0.5}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -5.09999999999999972e-30Initial program 11.4%
Taylor expanded in b around -inf 91.9%
associate-*r/91.9%
neg-mul-191.9%
Simplified91.9%
if -5.09999999999999972e-30 < b < 3.9e-43Initial program 74.7%
Simplified74.7%
pow1/274.7%
pow-to-exp70.0%
Applied egg-rr70.0%
Taylor expanded in c around -inf 37.1%
mul-1-neg37.1%
unsub-neg37.1%
*-commutative37.1%
Simplified37.1%
Taylor expanded in b around 0 36.7%
Taylor expanded in a around 0 36.7%
*-commutative36.7%
+-commutative36.7%
log-prod36.7%
log-div62.5%
exp-to-pow66.6%
associate-/r/66.6%
*-commutative66.6%
associate-/l*66.6%
metadata-eval66.6%
Simplified66.6%
if 3.9e-43 < b Initial program 70.8%
Taylor expanded in b around inf 94.2%
mul-1-neg94.2%
unsub-neg94.2%
Simplified94.2%
Final simplification84.4%
(FPCore (a b c) :precision binary64 (if (<= b -2e-310) (/ (- c) b) (- (/ c b) (/ b a))))
double code(double a, double b, double c) {
double tmp;
if (b <= -2e-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 <= (-2d-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 <= -2e-310) {
tmp = -c / b;
} else {
tmp = (c / b) - (b / a);
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -2e-310: tmp = -c / b else: tmp = (c / b) - (b / a) return tmp
function code(a, b, c) tmp = 0.0 if (b <= -2e-310) tmp = Float64(Float64(-c) / 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 <= -2e-310) tmp = -c / b; else tmp = (c / b) - (b / a); end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -2e-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 -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\
\end{array}
\end{array}
if b < -1.999999999999994e-310Initial program 31.4%
Taylor expanded in b around -inf 68.8%
associate-*r/68.8%
neg-mul-168.8%
Simplified68.8%
if -1.999999999999994e-310 < b Initial program 73.1%
Taylor expanded in b around inf 71.9%
mul-1-neg71.9%
unsub-neg71.9%
Simplified71.9%
Final simplification70.2%
(FPCore (a b c) :precision binary64 (if (<= b -1.08e+91) (/ c b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -1.08e+91) {
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 <= (-1.08d+91)) 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 <= -1.08e+91) {
tmp = c / b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -1.08e+91: tmp = c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -1.08e+91) tmp = Float64(c / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -1.08e+91) tmp = c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -1.08e+91], N[(c / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.08 \cdot 10^{+91}:\\
\;\;\;\;\frac{c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -1.08e91Initial program 8.9%
Taylor expanded in b around inf 1.9%
+-commutative1.9%
*-commutative1.9%
fma-def1.9%
*-commutative1.9%
associate-/l*2.3%
Simplified2.3%
Taylor expanded in b around 0 32.8%
if -1.08e91 < b Initial program 63.3%
Taylor expanded in b around inf 44.5%
associate-*r/44.5%
mul-1-neg44.5%
Simplified44.5%
Final simplification41.9%
(FPCore (a b c) :precision binary64 (if (<= b -5.2e-300) (/ (- c) b) (/ (- b) a)))
double code(double a, double b, double c) {
double tmp;
if (b <= -5.2e-300) {
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 <= (-5.2d-300)) 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 <= -5.2e-300) {
tmp = -c / b;
} else {
tmp = -b / a;
}
return tmp;
}
def code(a, b, c): tmp = 0 if b <= -5.2e-300: tmp = -c / b else: tmp = -b / a return tmp
function code(a, b, c) tmp = 0.0 if (b <= -5.2e-300) tmp = Float64(Float64(-c) / b); else tmp = Float64(Float64(-b) / a); end return tmp end
function tmp_2 = code(a, b, c) tmp = 0.0; if (b <= -5.2e-300) tmp = -c / b; else tmp = -b / a; end tmp_2 = tmp; end
code[a_, b_, c_] := If[LessEqual[b, -5.2e-300], N[((-c) / b), $MachinePrecision], N[((-b) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.2 \cdot 10^{-300}:\\
\;\;\;\;\frac{-c}{b}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b}{a}\\
\end{array}
\end{array}
if b < -5.19999999999999993e-300Initial program 30.1%
Taylor expanded in b around -inf 70.8%
associate-*r/70.8%
neg-mul-170.8%
Simplified70.8%
if -5.19999999999999993e-300 < b Initial program 73.1%
Taylor expanded in b around inf 69.1%
associate-*r/69.1%
mul-1-neg69.1%
Simplified69.1%
Final simplification70.0%
(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 32.5%
+-commutative32.5%
*-commutative32.5%
fma-def32.5%
*-commutative32.5%
associate-/l*34.9%
Simplified34.9%
Taylor expanded in b around 0 9.8%
Final simplification9.8%
(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 2023200
(FPCore (a b c)
:name "quadm (p42, negative)"
: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)))