
(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 10 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 -2.9e+32)
(* (/ a a) (/ c (fma b_2 -2.0 (* c (* 0.5 (/ a b_2))))))
(if (<= b_2 -2e-309)
(* (/ a a) (/ c (- (hypot b_2 (sqrt (* a (- c)))) b_2)))
(if (<= b_2 1e+127)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) 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 <= -2.9e+32) {
tmp = (a / a) * (c / fma(b_2, -2.0, (c * (0.5 * (a / b_2)))));
} else if (b_2 <= -2e-309) {
tmp = (a / a) * (c / (hypot(b_2, sqrt((a * -c))) - b_2));
} else if (b_2 <= 1e+127) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -2.9e+32) tmp = Float64(Float64(a / a) * Float64(c / fma(b_2, -2.0, Float64(c * Float64(0.5 * Float64(a / b_2)))))); elseif (b_2 <= -2e-309) tmp = Float64(Float64(a / a) * Float64(c / Float64(hypot(b_2, sqrt(Float64(a * Float64(-c)))) - b_2))); elseif (b_2 <= 1e+127) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.9e+32], N[(N[(a / a), $MachinePrecision] * N[(c / N[(b$95$2 * -2.0 + N[(c * N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -2e-309], N[(N[(a / a), $MachinePrecision] * N[(c / N[(N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1e+127], 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], 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 -2.9 \cdot 10^{+32}:\\
\;\;\;\;\frac{a}{a} \cdot \frac{c}{\mathsf{fma}\left(b_2, -2, c \cdot \left(0.5 \cdot \frac{a}{b_2}\right)\right)}\\
\mathbf{elif}\;b_2 \leq -2 \cdot 10^{-309}:\\
\;\;\;\;\frac{a}{a} \cdot \frac{c}{\mathsf{hypot}\left(b_2, \sqrt{a \cdot \left(-c\right)}\right) - b_2}\\
\mathbf{elif}\;b_2 \leq 10^{+127}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -2.90000000000000003e32Initial program 8.2%
prod-diff8.2%
*-commutative8.2%
fma-neg8.2%
prod-diff8.2%
*-commutative8.2%
fma-neg8.2%
associate-+l+8.2%
*-commutative8.2%
fma-udef8.2%
distribute-lft-neg-in8.2%
*-commutative8.2%
distribute-rgt-neg-in8.2%
fma-def8.2%
*-commutative8.2%
fma-udef8.2%
distribute-lft-neg-in8.2%
*-commutative8.2%
distribute-rgt-neg-in8.2%
fma-def8.2%
Applied egg-rr8.2%
*-commutative8.2%
count-28.2%
*-commutative8.2%
Simplified8.2%
flip--7.1%
add-sqr-sqrt7.1%
*-commutative7.1%
*-commutative7.1%
Applied egg-rr7.1%
Simplified59.9%
div-inv59.9%
sub-neg59.9%
distribute-rgt-neg-out59.9%
add-sqr-sqrt35.2%
hypot-udef51.1%
Applied egg-rr51.1%
times-frac48.9%
*-rgt-identity48.9%
*-commutative48.9%
*-commutative48.9%
times-frac54.8%
Simplified54.8%
Taylor expanded in b_2 around -inf 0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
associate-*r*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt96.1%
associate-*l*96.1%
*-commutative96.1%
associate-*l*96.1%
metadata-eval96.1%
associate-/l*98.7%
*-rgt-identity98.7%
associate-*r/98.7%
associate-*l*98.7%
associate-/r/98.7%
*-commutative98.7%
associate-*r/98.7%
*-rgt-identity98.7%
Simplified98.7%
if -2.90000000000000003e32 < b_2 < -1.9999999999999988e-309Initial program 59.5%
prod-diff59.1%
*-commutative59.1%
fma-neg59.1%
prod-diff59.1%
*-commutative59.1%
fma-neg59.1%
associate-+l+59.0%
*-commutative59.0%
fma-udef59.1%
distribute-lft-neg-in59.1%
*-commutative59.1%
distribute-rgt-neg-in59.1%
fma-def59.0%
*-commutative59.0%
fma-udef59.1%
distribute-lft-neg-in59.1%
*-commutative59.1%
distribute-rgt-neg-in59.1%
fma-def59.0%
Applied egg-rr59.0%
*-commutative59.0%
count-259.0%
*-commutative59.0%
Simplified59.0%
flip--58.9%
add-sqr-sqrt59.0%
*-commutative59.0%
*-commutative59.0%
Applied egg-rr59.0%
Simplified71.7%
div-inv71.5%
sub-neg71.5%
distribute-rgt-neg-out71.5%
add-sqr-sqrt69.8%
hypot-udef69.8%
Applied egg-rr69.8%
times-frac63.8%
*-rgt-identity63.8%
*-commutative63.8%
*-commutative63.8%
times-frac85.4%
Simplified85.4%
if -1.9999999999999988e-309 < b_2 < 9.99999999999999955e126Initial program 85.8%
if 9.99999999999999955e126 < b_2 Initial program 45.5%
Taylor expanded in b_2 around inf 97.9%
Final simplification91.5%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -9.8e-79)
(* (/ a a) (/ c (fma b_2 -2.0 (* c (* 0.5 (/ a b_2))))))
(if (<= b_2 7.7e+127)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) 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 <= -9.8e-79) {
tmp = (a / a) * (c / fma(b_2, -2.0, (c * (0.5 * (a / b_2)))));
} else if (b_2 <= 7.7e+127) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -9.8e-79) tmp = Float64(Float64(a / a) * Float64(c / fma(b_2, -2.0, Float64(c * Float64(0.5 * Float64(a / b_2)))))); elseif (b_2 <= 7.7e+127) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a); else tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -9.8e-79], N[(N[(a / a), $MachinePrecision] * N[(c / N[(b$95$2 * -2.0 + N[(c * N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 7.7e+127], 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], 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 -9.8 \cdot 10^{-79}:\\
\;\;\;\;\frac{a}{a} \cdot \frac{c}{\mathsf{fma}\left(b_2, -2, c \cdot \left(0.5 \cdot \frac{a}{b_2}\right)\right)}\\
\mathbf{elif}\;b_2 \leq 7.7 \cdot 10^{+127}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -9.8000000000000001e-79Initial program 16.2%
prod-diff16.1%
*-commutative16.1%
fma-neg16.1%
prod-diff16.1%
*-commutative16.1%
fma-neg16.1%
associate-+l+16.1%
*-commutative16.1%
fma-udef16.1%
distribute-lft-neg-in16.1%
*-commutative16.1%
distribute-rgt-neg-in16.1%
fma-def16.1%
*-commutative16.1%
fma-udef16.1%
distribute-lft-neg-in16.1%
*-commutative16.1%
distribute-rgt-neg-in16.1%
fma-def16.1%
Applied egg-rr16.1%
*-commutative16.1%
count-216.1%
*-commutative16.1%
Simplified16.1%
flip--15.3%
add-sqr-sqrt15.3%
*-commutative15.3%
*-commutative15.3%
Applied egg-rr15.3%
Simplified61.6%
div-inv61.6%
sub-neg61.6%
distribute-rgt-neg-out61.6%
add-sqr-sqrt42.5%
hypot-udef54.1%
Applied egg-rr54.1%
times-frac49.7%
*-rgt-identity49.7%
*-commutative49.7%
*-commutative49.7%
times-frac64.0%
Simplified64.0%
Taylor expanded in b_2 around -inf 0.0%
*-commutative0.0%
fma-def0.0%
associate-*r/0.0%
associate-*r*0.0%
associate-*r*0.0%
unpow20.0%
rem-square-sqrt88.4%
associate-*l*88.4%
*-commutative88.4%
associate-*l*88.4%
metadata-eval88.4%
associate-/l*90.3%
*-rgt-identity90.3%
associate-*r/90.3%
associate-*l*90.3%
associate-/r/90.3%
*-commutative90.3%
associate-*r/90.3%
*-rgt-identity90.3%
Simplified90.3%
if -9.8000000000000001e-79 < b_2 < 7.6999999999999996e127Initial program 83.0%
if 7.6999999999999996e127 < b_2 Initial program 45.5%
Taylor expanded in b_2 around inf 97.9%
Final simplification88.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.5e-83)
(/ (* c -0.5) b_2)
(if (<= b_2 7e+127)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) 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 <= -4.5e-83) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 7e+127) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / 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 <= (-4.5d-83)) then
tmp = (c * (-0.5d0)) / b_2
else if (b_2 <= 7d+127) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -4.5e-83) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 7e+127) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -4.5e-83: tmp = (c * -0.5) / b_2 elif b_2 <= 7e+127: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (a * c)))) / 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 <= -4.5e-83) tmp = Float64(Float64(c * -0.5) / b_2); elseif (b_2 <= 7e+127) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / 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 <= -4.5e-83) tmp = (c * -0.5) / b_2; elseif (b_2 <= 7e+127) tmp = (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / 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, -4.5e-83], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 7e+127], 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], 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 -4.5 \cdot 10^{-83}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{elif}\;b_2 \leq 7 \cdot 10^{+127}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -4.49999999999999997e-83Initial program 16.2%
Taylor expanded in b_2 around -inf 90.0%
associate-*r/90.0%
Simplified90.0%
if -4.49999999999999997e-83 < b_2 < 6.99999999999999956e127Initial program 83.0%
if 6.99999999999999956e127 < b_2 Initial program 45.5%
Taylor expanded in b_2 around inf 97.9%
Final simplification88.3%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.2e-79)
(/ (* c -0.5) b_2)
(if (<= b_2 7.5e-57)
(/ (- (- b_2) (sqrt (* a (- c)))) 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 <= -4.2e-79) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 7.5e-57) {
tmp = (-b_2 - sqrt((a * -c))) / 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 <= (-4.2d-79)) then
tmp = (c * (-0.5d0)) / b_2
else if (b_2 <= 7.5d-57) then
tmp = (-b_2 - sqrt((a * -c))) / 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 <= -4.2e-79) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 7.5e-57) {
tmp = (-b_2 - Math.sqrt((a * -c))) / 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 <= -4.2e-79: tmp = (c * -0.5) / b_2 elif b_2 <= 7.5e-57: tmp = (-b_2 - math.sqrt((a * -c))) / 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 <= -4.2e-79) tmp = Float64(Float64(c * -0.5) / b_2); elseif (b_2 <= 7.5e-57) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(a * Float64(-c)))) / 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 <= -4.2e-79) tmp = (c * -0.5) / b_2; elseif (b_2 <= 7.5e-57) tmp = (-b_2 - sqrt((a * -c))) / 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, -4.2e-79], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 7.5e-57], N[(N[((-b$95$2) - N[Sqrt[N[(a * (-c)), $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 -4.2 \cdot 10^{-79}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{elif}\;b_2 \leq 7.5 \cdot 10^{-57}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -4.1999999999999999e-79Initial program 16.2%
Taylor expanded in b_2 around -inf 90.0%
associate-*r/90.0%
Simplified90.0%
if -4.1999999999999999e-79 < b_2 < 7.49999999999999973e-57Initial program 76.4%
Taylor expanded in b_2 around 0 74.1%
mul-1-neg74.1%
distribute-rgt-neg-out74.1%
Simplified74.1%
if 7.49999999999999973e-57 < b_2 Initial program 69.1%
Taylor expanded in b_2 around inf 89.8%
Final simplification85.5%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4e-80)
(/ (* c -0.5) b_2)
(if (<= b_2 8e-142)
(/ (- (sqrt (* a (- c)))) 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 <= -4e-80) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 8e-142) {
tmp = -sqrt((a * -c)) / 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 <= (-4d-80)) then
tmp = (c * (-0.5d0)) / b_2
else if (b_2 <= 8d-142) then
tmp = -sqrt((a * -c)) / 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 <= -4e-80) {
tmp = (c * -0.5) / b_2;
} else if (b_2 <= 8e-142) {
tmp = -Math.sqrt((a * -c)) / 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 <= -4e-80: tmp = (c * -0.5) / b_2 elif b_2 <= 8e-142: tmp = -math.sqrt((a * -c)) / 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 <= -4e-80) tmp = Float64(Float64(c * -0.5) / b_2); elseif (b_2 <= 8e-142) tmp = Float64(Float64(-sqrt(Float64(a * Float64(-c)))) / 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 <= -4e-80) tmp = (c * -0.5) / b_2; elseif (b_2 <= 8e-142) tmp = -sqrt((a * -c)) / 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, -4e-80], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 8e-142], N[((-N[Sqrt[N[(a * (-c)), $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 -4 \cdot 10^{-80}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{elif}\;b_2 \leq 8 \cdot 10^{-142}:\\
\;\;\;\;\frac{-\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.99999999999999985e-80Initial program 16.2%
Taylor expanded in b_2 around -inf 90.0%
associate-*r/90.0%
Simplified90.0%
if -3.99999999999999985e-80 < b_2 < 8.0000000000000003e-142Initial program 76.1%
prod-diff75.7%
*-commutative75.7%
fma-neg75.7%
prod-diff75.7%
*-commutative75.7%
fma-neg75.7%
associate-+l+75.5%
*-commutative75.5%
fma-udef75.7%
distribute-lft-neg-in75.7%
*-commutative75.7%
distribute-rgt-neg-in75.7%
fma-def75.5%
*-commutative75.5%
fma-udef75.7%
distribute-lft-neg-in75.7%
*-commutative75.7%
distribute-rgt-neg-in75.7%
fma-def75.5%
Applied egg-rr75.5%
*-commutative75.5%
count-275.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in b_2 around 0 74.3%
mul-1-neg74.3%
distribute-lft1-in74.3%
metadata-eval74.3%
mul0-lft74.7%
metadata-eval74.7%
neg-sub074.7%
distribute-rgt-neg-out74.7%
Simplified74.7%
if 8.0000000000000003e-142 < b_2 Initial program 69.7%
Taylor expanded in b_2 around inf 87.2%
Final simplification85.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (/ (* c -0.5) 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 <= -5e-310) {
tmp = (c * -0.5) / 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 <= (-5d-310)) then
tmp = (c * (-0.5d0)) / 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 <= -5e-310) {
tmp = (c * -0.5) / 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 <= -5e-310: tmp = (c * -0.5) / 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 <= -5e-310) tmp = Float64(Float64(c * -0.5) / 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 <= -5e-310) tmp = (c * -0.5) / 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, -5e-310], N[(N[(c * -0.5), $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 -5 \cdot 10^{-310}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 31.5%
Taylor expanded in b_2 around -inf 69.8%
associate-*r/69.8%
Simplified69.8%
if -4.999999999999985e-310 < b_2 Initial program 71.3%
Taylor expanded in b_2 around inf 68.0%
Final simplification68.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3.5e-302) (* c (/ -0.5 b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-302) {
tmp = c * (-0.5 / b_2);
} 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 <= (-3.5d-302)) then
tmp = c * ((-0.5d0) / b_2)
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 <= -3.5e-302) {
tmp = c * (-0.5 / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.5e-302: tmp = c * (-0.5 / b_2) else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.5e-302) tmp = Float64(c * Float64(-0.5 / b_2)); 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 <= -3.5e-302) tmp = c * (-0.5 / b_2); else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.5e-302], N[(c * N[(-0.5 / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.5 \cdot 10^{-302}:\\
\;\;\;\;c \cdot \frac{-0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -3.5000000000000001e-302Initial program 31.0%
frac-2neg31.0%
div-inv31.0%
Applied egg-rr40.3%
Taylor expanded in b_2 around -inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt70.3%
associate-*r*70.3%
metadata-eval70.3%
*-commutative70.3%
*-rgt-identity70.3%
associate-*r/70.1%
associate-*l*70.1%
associate-*r/70.1%
metadata-eval70.1%
Simplified70.1%
if -3.5000000000000001e-302 < b_2 Initial program 71.5%
Taylor expanded in b_2 around 0 41.1%
mul-1-neg41.1%
distribute-rgt-neg-out41.1%
Simplified41.1%
Taylor expanded in b_2 around inf 24.0%
mul-1-neg24.0%
distribute-frac-neg24.0%
Simplified24.0%
Final simplification48.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -7e-303) (/ (* c -0.5) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7e-303) {
tmp = (c * -0.5) / b_2;
} 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 <= (-7d-303)) then
tmp = (c * (-0.5d0)) / b_2
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 <= -7e-303) {
tmp = (c * -0.5) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7e-303: tmp = (c * -0.5) / b_2 else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7e-303) tmp = Float64(Float64(c * -0.5) / b_2); 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 <= -7e-303) tmp = (c * -0.5) / b_2; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7e-303], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7 \cdot 10^{-303}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -7e-303Initial program 31.0%
Taylor expanded in b_2 around -inf 70.3%
associate-*r/70.3%
Simplified70.3%
if -7e-303 < b_2 Initial program 71.5%
Taylor expanded in b_2 around 0 41.1%
mul-1-neg41.1%
distribute-rgt-neg-out41.1%
Simplified41.1%
Taylor expanded in b_2 around inf 24.0%
mul-1-neg24.0%
distribute-frac-neg24.0%
Simplified24.0%
Final simplification48.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -7e-303) (/ (* c -0.5) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7e-303) {
tmp = (c * -0.5) / b_2;
} else {
tmp = (b_2 * -2.0) / 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 <= (-7d-303)) then
tmp = (c * (-0.5d0)) / b_2
else
tmp = (b_2 * (-2.0d0)) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7e-303) {
tmp = (c * -0.5) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7e-303: tmp = (c * -0.5) / b_2 else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7e-303) tmp = Float64(Float64(c * -0.5) / b_2); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7e-303) tmp = (c * -0.5) / b_2; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7e-303], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7 \cdot 10^{-303}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -7e-303Initial program 31.0%
Taylor expanded in b_2 around -inf 70.3%
associate-*r/70.3%
Simplified70.3%
if -7e-303 < b_2 Initial program 71.5%
Taylor expanded in b_2 around inf 66.4%
*-commutative66.4%
Simplified66.4%
Final simplification68.5%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / 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 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b_2}{a}
\end{array}
Initial program 50.5%
Taylor expanded in b_2 around 0 32.9%
mul-1-neg32.9%
distribute-rgt-neg-out32.9%
Simplified32.9%
Taylor expanded in b_2 around inf 12.9%
mul-1-neg12.9%
distribute-frac-neg12.9%
Simplified12.9%
Final simplification12.9%
herbie shell --seed 2023201
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))