
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-151)
(/ (* -0.5 c) b_2)
(if (<= b_2 5.8e-28)
(* (+ b_2 (hypot b_2 (sqrt (* c (- a))))) (/ 1.0 (- a)))
(+
(* -2.0 (/ b_2 a))
(/ (/ (* c 0.5) (pow b_2 0.6666666666666666)) (cbrt b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 5.8e-28) {
tmp = (b_2 + hypot(b_2, sqrt((c * -a)))) * (1.0 / -a);
} else {
tmp = (-2.0 * (b_2 / a)) + (((c * 0.5) / pow(b_2, 0.6666666666666666)) / cbrt(b_2));
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 5.8e-28) {
tmp = (b_2 + Math.hypot(b_2, Math.sqrt((c * -a)))) * (1.0 / -a);
} else {
tmp = (-2.0 * (b_2 / a)) + (((c * 0.5) / Math.pow(b_2, 0.6666666666666666)) / Math.cbrt(b_2));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-151) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 5.8e-28) tmp = Float64(Float64(b_2 + hypot(b_2, sqrt(Float64(c * Float64(-a))))) * Float64(1.0 / Float64(-a))); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(Float64(Float64(c * 0.5) / (b_2 ^ 0.6666666666666666)) / cbrt(b_2))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-151], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 5.8e-28], N[(N[(b$95$2 + N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 / (-a)), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(c * 0.5), $MachinePrecision] / N[Power[b$95$2, 0.6666666666666666], $MachinePrecision]), $MachinePrecision] / N[Power[b$95$2, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-151}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 5.8 \cdot 10^{-28}:\\
\;\;\;\;\left(b_2 + \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right) \cdot \frac{1}{-a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + \frac{\frac{c \cdot 0.5}{{b_2}^{0.6666666666666666}}}{\sqrt[3]{b_2}}\\
\end{array}
\end{array}
if b_2 < -3.20000000000000021e-151Initial program 11.1%
Taylor expanded in b_2 around -inf 84.0%
associate-*r/84.0%
Simplified84.0%
if -3.20000000000000021e-151 < b_2 < 5.80000000000000026e-28Initial program 80.1%
frac-2neg80.1%
div-inv80.0%
Applied egg-rr81.8%
if 5.80000000000000026e-28 < b_2 Initial program 69.5%
Taylor expanded in b_2 around inf 88.6%
associate-*r/88.6%
add-cube-cbrt88.6%
associate-/r*88.6%
*-commutative88.6%
cbrt-unprod88.3%
Applied egg-rr88.3%
pow1/388.3%
pow-prod-down88.6%
pow-prod-up88.6%
metadata-eval88.6%
Applied egg-rr88.6%
Final simplification84.8%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-151)
(/ (* -0.5 c) b_2)
(if (<= b_2 2.8e-28)
(* (+ b_2 (hypot b_2 (sqrt (* c (- a))))) (/ 1.0 (- a)))
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.8e-28) {
tmp = (b_2 + hypot(b_2, sqrt((c * -a)))) * (1.0 / -a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.8e-28) {
tmp = (b_2 + Math.hypot(b_2, Math.sqrt((c * -a)))) * (1.0 / -a);
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-151: tmp = (-0.5 * c) / b_2 elif b_2 <= 2.8e-28: tmp = (b_2 + math.hypot(b_2, math.sqrt((c * -a)))) * (1.0 / -a) else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-151) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 2.8e-28) tmp = Float64(Float64(b_2 + hypot(b_2, sqrt(Float64(c * Float64(-a))))) * Float64(1.0 / Float64(-a))); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.2e-151) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 2.8e-28) tmp = (b_2 + hypot(b_2, sqrt((c * -a)))) * (1.0 / -a); else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-151], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2.8e-28], N[(N[(b$95$2 + N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] * N[(1.0 / (-a)), $MachinePrecision]), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-151}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2.8 \cdot 10^{-28}:\\
\;\;\;\;\left(b_2 + \mathsf{hypot}\left(b_2, \sqrt{c \cdot \left(-a\right)}\right)\right) \cdot \frac{1}{-a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.20000000000000021e-151Initial program 11.1%
Taylor expanded in b_2 around -inf 84.0%
associate-*r/84.0%
Simplified84.0%
if -3.20000000000000021e-151 < b_2 < 2.7999999999999998e-28Initial program 80.1%
frac-2neg80.1%
div-inv80.0%
Applied egg-rr81.8%
if 2.7999999999999998e-28 < b_2 Initial program 69.5%
Taylor expanded in b_2 around inf 88.6%
Final simplification84.8%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3e-151)
(/ (* -0.5 c) b_2)
(if (<= b_2 2750.0)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2750.0) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-3d-151)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 2750.0d0) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3e-151) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2750.0) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3e-151: tmp = (-0.5 * c) / b_2 elif b_2 <= 2750.0: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3e-151) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 2750.0) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3e-151) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 2750.0) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3e-151], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2750.0], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3 \cdot 10^{-151}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2750:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3e-151Initial program 11.1%
Taylor expanded in b_2 around -inf 84.0%
associate-*r/84.0%
Simplified84.0%
if -3e-151 < b_2 < 2750Initial program 81.2%
if 2750 < b_2 Initial program 67.6%
Taylor expanded in b_2 around inf 89.1%
Final simplification84.7%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8e-152)
(/ (* -0.5 c) b_2)
(if (<= b_2 4.6e-131)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-152) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 4.6e-131) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-8d-152)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 4.6d-131) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-152) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 4.6e-131) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8e-152: tmp = (-0.5 * c) / b_2 elif b_2 <= 4.6e-131: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8e-152) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 4.6e-131) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8e-152) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 4.6e-131) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8e-152], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 4.6e-131], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8 \cdot 10^{-152}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 4.6 \cdot 10^{-131}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -8.00000000000000053e-152Initial program 11.1%
Taylor expanded in b_2 around -inf 84.0%
associate-*r/84.0%
Simplified84.0%
if -8.00000000000000053e-152 < b_2 < 4.60000000000000044e-131Initial program 80.3%
Taylor expanded in b_2 around 0 79.0%
mul-1-neg79.0%
distribute-rgt-neg-out79.0%
Simplified79.0%
if 4.60000000000000044e-131 < b_2 Initial program 71.3%
Taylor expanded in b_2 around inf 80.7%
Final simplification81.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-311) (/ (* -0.5 c) b_2) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1d-311)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-311: tmp = (-0.5 * c) / b_2 else: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-311) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-311) tmp = (-0.5 * c) / b_2; else tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-311], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -9.99999999999948e-312Initial program 28.2%
Taylor expanded in b_2 around -inf 66.5%
associate-*r/66.5%
Simplified66.5%
if -9.99999999999948e-312 < b_2 Initial program 72.6%
Taylor expanded in b_2 around inf 64.3%
Final simplification65.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-311) (/ 0.0 a) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = 0.0 / a;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1d-311)) then
tmp = 0.0d0 / a
else
tmp = (-2.0d0) * (b_2 / a)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = 0.0 / a;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-311: tmp = 0.0 / a else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-311) tmp = Float64(0.0 / a); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-311) tmp = 0.0 / a; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-311], N[(0.0 / a), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -9.99999999999948e-312Initial program 28.2%
add-sqr-sqrt25.5%
pow225.5%
pow1/225.5%
sqrt-pow125.5%
metadata-eval25.5%
Applied egg-rr25.5%
Taylor expanded in b_2 around -inf 25.1%
distribute-lft1-in25.1%
metadata-eval25.1%
mul0-lft25.1%
Simplified25.1%
if -9.99999999999948e-312 < b_2 Initial program 72.6%
Taylor expanded in b_2 around inf 63.9%
Final simplification46.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-311) (/ (* -0.5 c) b_2) (* -2.0 (/ b_2 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1d-311)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (-2.0d0) * (b_2 / a)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 * (b_2 / a);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-311: tmp = (-0.5 * c) / b_2 else: tmp = -2.0 * (b_2 / a) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-311) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(-2.0 * Float64(b_2 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-311) tmp = (-0.5 * c) / b_2; else tmp = -2.0 * (b_2 / a); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-311], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\end{array}
\end{array}
if b_2 < -9.99999999999948e-312Initial program 28.2%
Taylor expanded in b_2 around -inf 66.5%
associate-*r/66.5%
Simplified66.5%
if -9.99999999999948e-312 < b_2 Initial program 72.6%
Taylor expanded in b_2 around inf 63.9%
Final simplification65.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1e-311) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
real(8) :: tmp
if (b_2 <= (-1d-311)) then
tmp = 0.0d0 / a
else
tmp = -b_2 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1e-311) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1e-311: tmp = 0.0 / a else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1e-311) tmp = Float64(0.0 / a); else tmp = Float64(Float64(-b_2) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1e-311) tmp = 0.0 / a; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1e-311], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1 \cdot 10^{-311}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -9.99999999999948e-312Initial program 28.2%
add-sqr-sqrt25.5%
pow225.5%
pow1/225.5%
sqrt-pow125.5%
metadata-eval25.5%
Applied egg-rr25.5%
Taylor expanded in b_2 around -inf 25.1%
distribute-lft1-in25.1%
metadata-eval25.1%
mul0-lft25.1%
Simplified25.1%
if -9.99999999999948e-312 < b_2 Initial program 72.6%
add-sqr-sqrt72.4%
pow272.4%
pow1/272.4%
sqrt-pow172.4%
metadata-eval72.4%
Applied egg-rr72.4%
Taylor expanded in b_2 around inf 26.7%
mul-1-neg26.7%
Simplified26.7%
Final simplification25.9%
(FPCore (a b_2 c) :precision binary64 (/ 0.0 a))
double code(double a, double b_2, double c) {
return 0.0 / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = 0.0d0 / a
end function
public static double code(double a, double b_2, double c) {
return 0.0 / a;
}
def code(a, b_2, c): return 0.0 / a
function code(a, b_2, c) return Float64(0.0 / a) end
function tmp = code(a, b_2, c) tmp = 0.0 / a; end
code[a_, b$95$2_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 52.3%
add-sqr-sqrt51.0%
pow251.0%
pow1/251.0%
sqrt-pow151.0%
metadata-eval51.0%
Applied egg-rr51.0%
Taylor expanded in b_2 around -inf 12.9%
distribute-lft1-in12.9%
metadata-eval12.9%
mul0-lft12.9%
Simplified12.9%
Final simplification12.9%
herbie shell --seed 2023240
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))