
(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
(let* ((t_0 (sqrt (- (* b_2 b_2) (* a c)))))
(if (<= b_2 -1.9e+69)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 -1.1e-105)
(/ (/ (* a c) (fma -1.0 b_2 t_0)) a)
(if (<= b_2 7.5e+118)
(/ (- (- b_2) t_0) a)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(((b_2 * b_2) - (a * c)));
double tmp;
if (b_2 <= -1.9e+69) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= -1.1e-105) {
tmp = ((a * c) / fma(-1.0, b_2, t_0)) / a;
} else if (b_2 <= 7.5e+118) {
tmp = (-b_2 - t_0) / a;
} else {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
}
return tmp;
}
function code(a, b_2, c) t_0 = sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) tmp = 0.0 if (b_2 <= -1.9e+69) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= -1.1e-105) tmp = Float64(Float64(Float64(a * c) / fma(-1.0, b_2, t_0)) / a); elseif (b_2 <= 7.5e+118) tmp = Float64(Float64(Float64(-b_2) - t_0) / 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_] := Block[{t$95$0 = N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[b$95$2, -1.9e+69], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -1.1e-105], N[(N[(N[(a * c), $MachinePrecision] / N[(-1.0 * b$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 7.5e+118], N[(N[((-b$95$2) - t$95$0), $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}
t_0 := \sqrt{b_2 \cdot b_2 - a \cdot c}\\
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{+69}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq -1.1 \cdot 10^{-105}:\\
\;\;\;\;\frac{\frac{a \cdot c}{\mathsf{fma}\left(-1, b_2, t_0\right)}}{a}\\
\mathbf{elif}\;b_2 \leq 7.5 \cdot 10^{+118}:\\
\;\;\;\;\frac{\left(-b_2\right) - t_0}{a}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.90000000000000014e69Initial program 12.5%
prod-diff12.3%
*-commutative12.3%
fma-neg12.3%
prod-diff12.3%
*-commutative12.3%
fma-neg12.3%
associate-+l+12.3%
*-commutative12.3%
fma-udef12.3%
distribute-lft-neg-in12.3%
*-commutative12.3%
distribute-rgt-neg-in12.3%
fma-def12.3%
*-commutative12.3%
fma-udef12.3%
distribute-lft-neg-in12.3%
*-commutative12.3%
distribute-rgt-neg-in12.3%
fma-def12.3%
Applied egg-rr12.3%
*-commutative12.3%
count-212.3%
*-commutative12.3%
Simplified12.3%
clear-num12.3%
inv-pow12.3%
+-commutative12.3%
*-commutative12.3%
fma-def12.3%
*-commutative12.3%
*-commutative12.3%
Applied egg-rr12.3%
unpow-112.3%
fma-udef12.3%
fma-def12.3%
*-commutative12.3%
neg-mul-112.3%
associate-*r*12.3%
*-commutative12.3%
distribute-lft1-in12.3%
metadata-eval12.3%
mul0-lft12.5%
metadata-eval12.5%
associate-+r-12.5%
Simplified12.5%
Taylor expanded in b_2 around -inf 94.9%
if -1.90000000000000014e69 < b_2 < -1.10000000000000002e-105Initial program 44.5%
prod-diff44.4%
*-commutative44.4%
fma-neg44.3%
prod-diff44.4%
*-commutative44.4%
fma-neg44.3%
associate-+l+44.3%
*-commutative44.3%
fma-udef44.3%
distribute-lft-neg-in44.3%
*-commutative44.3%
distribute-rgt-neg-in44.3%
fma-def44.3%
*-commutative44.3%
fma-udef44.3%
distribute-lft-neg-in44.3%
*-commutative44.3%
distribute-rgt-neg-in44.3%
fma-def44.3%
Applied egg-rr44.3%
*-commutative44.3%
count-244.3%
*-commutative44.3%
Simplified44.3%
flip--44.0%
pow244.0%
add-sqr-sqrt44.5%
+-commutative44.5%
*-commutative44.5%
fma-def44.5%
*-commutative44.5%
*-commutative44.5%
Applied egg-rr44.5%
Simplified81.8%
if -1.10000000000000002e-105 < b_2 < 7.50000000000000003e118Initial program 82.4%
if 7.50000000000000003e118 < b_2 Initial program 50.1%
Taylor expanded in b_2 around inf 97.9%
Final simplification88.0%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.5e-62)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 2.15e+120)
(/ (- (- 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 <= -1.5e-62) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 2.15e+120) {
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 <= (-1.5d-62)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 2.15d+120) 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 <= -1.5e-62) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 2.15e+120) {
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 <= -1.5e-62: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 2.15e+120: 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 <= -1.5e-62) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 2.15e+120) 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 <= -1.5e-62) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 2.15e+120) 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, -1.5e-62], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 2.15e+120], 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 -1.5 \cdot 10^{-62}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 2.15 \cdot 10^{+120}:\\
\;\;\;\;\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 < -1.5000000000000001e-62Initial program 21.2%
prod-diff21.1%
*-commutative21.1%
fma-neg21.1%
prod-diff21.1%
*-commutative21.1%
fma-neg21.1%
associate-+l+21.1%
*-commutative21.1%
fma-udef21.1%
distribute-lft-neg-in21.1%
*-commutative21.1%
distribute-rgt-neg-in21.1%
fma-def21.1%
*-commutative21.1%
fma-udef21.1%
distribute-lft-neg-in21.1%
*-commutative21.1%
distribute-rgt-neg-in21.1%
fma-def21.1%
Applied egg-rr21.1%
*-commutative21.1%
count-221.1%
*-commutative21.1%
Simplified21.1%
clear-num21.1%
inv-pow21.1%
+-commutative21.1%
*-commutative21.1%
fma-def21.1%
*-commutative21.1%
*-commutative21.1%
Applied egg-rr21.1%
unpow-121.1%
fma-udef21.1%
fma-def21.0%
*-commutative21.0%
neg-mul-121.0%
associate-*r*21.0%
*-commutative21.0%
distribute-lft1-in21.0%
metadata-eval21.0%
mul0-lft21.2%
metadata-eval21.2%
associate-+r-21.2%
Simplified21.2%
Taylor expanded in b_2 around -inf 85.3%
if -1.5000000000000001e-62 < b_2 < 2.1500000000000001e120Initial program 80.2%
if 2.1500000000000001e120 < b_2 Initial program 50.1%
Taylor expanded in b_2 around inf 97.9%
Final simplification85.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7.5e-67)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 3.2e-42)
(/ (- (- 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 <= -7.5e-67) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 3.2e-42) {
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 <= (-7.5d-67)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 3.2d-42) 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 <= -7.5e-67) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 3.2e-42) {
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 <= -7.5e-67: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 3.2e-42: 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 <= -7.5e-67) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 3.2e-42) 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 <= -7.5e-67) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 3.2e-42) 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, -7.5e-67], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 3.2e-42], 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 -7.5 \cdot 10^{-67}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 3.2 \cdot 10^{-42}:\\
\;\;\;\;\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 < -7.5000000000000005e-67Initial program 22.4%
prod-diff22.2%
*-commutative22.2%
fma-neg22.2%
prod-diff22.2%
*-commutative22.2%
fma-neg22.2%
associate-+l+22.2%
*-commutative22.2%
fma-udef22.2%
distribute-lft-neg-in22.2%
*-commutative22.2%
distribute-rgt-neg-in22.2%
fma-def22.2%
*-commutative22.2%
fma-udef22.2%
distribute-lft-neg-in22.2%
*-commutative22.2%
distribute-rgt-neg-in22.2%
fma-def22.2%
Applied egg-rr22.2%
*-commutative22.2%
count-222.2%
*-commutative22.2%
Simplified22.2%
clear-num22.2%
inv-pow22.2%
+-commutative22.2%
*-commutative22.2%
fma-def22.2%
*-commutative22.2%
*-commutative22.2%
Applied egg-rr22.2%
unpow-122.2%
fma-udef22.2%
fma-def22.2%
*-commutative22.2%
neg-mul-122.2%
associate-*r*22.2%
*-commutative22.2%
distribute-lft1-in22.2%
metadata-eval22.2%
mul0-lft22.3%
metadata-eval22.3%
associate-+r-22.3%
Simplified22.3%
Taylor expanded in b_2 around -inf 84.9%
if -7.5000000000000005e-67 < b_2 < 3.20000000000000025e-42Initial program 74.3%
Taylor expanded in b_2 around 0 64.1%
mul-1-neg64.1%
distribute-rgt-neg-out64.1%
Simplified64.1%
if 3.20000000000000025e-42 < b_2 Initial program 70.2%
Taylor expanded in b_2 around inf 91.6%
Final simplification80.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -4.6e-69)
(/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c))))
(if (<= b_2 5.5e-42)
(/ (- (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.6e-69) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 5.5e-42) {
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 <= (-4.6d-69)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
else if (b_2 <= 5.5d-42) 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 <= -4.6e-69) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} else if (b_2 <= 5.5e-42) {
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 <= -4.6e-69: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) elif b_2 <= 5.5e-42: 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 <= -4.6e-69) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); elseif (b_2 <= 5.5e-42) 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 <= -4.6e-69) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); elseif (b_2 <= 5.5e-42) 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, -4.6e-69], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 5.5e-42], 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.6 \cdot 10^{-69}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{elif}\;b_2 \leq 5.5 \cdot 10^{-42}:\\
\;\;\;\;\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 < -4.6000000000000001e-69Initial program 22.4%
prod-diff22.2%
*-commutative22.2%
fma-neg22.2%
prod-diff22.2%
*-commutative22.2%
fma-neg22.2%
associate-+l+22.2%
*-commutative22.2%
fma-udef22.2%
distribute-lft-neg-in22.2%
*-commutative22.2%
distribute-rgt-neg-in22.2%
fma-def22.2%
*-commutative22.2%
fma-udef22.2%
distribute-lft-neg-in22.2%
*-commutative22.2%
distribute-rgt-neg-in22.2%
fma-def22.2%
Applied egg-rr22.2%
*-commutative22.2%
count-222.2%
*-commutative22.2%
Simplified22.2%
clear-num22.2%
inv-pow22.2%
+-commutative22.2%
*-commutative22.2%
fma-def22.2%
*-commutative22.2%
*-commutative22.2%
Applied egg-rr22.2%
unpow-122.2%
fma-udef22.2%
fma-def22.2%
*-commutative22.2%
neg-mul-122.2%
associate-*r*22.2%
*-commutative22.2%
distribute-lft1-in22.2%
metadata-eval22.2%
mul0-lft22.3%
metadata-eval22.3%
associate-+r-22.3%
Simplified22.3%
Taylor expanded in b_2 around -inf 84.9%
if -4.6000000000000001e-69 < b_2 < 5.5e-42Initial program 74.3%
prod-diff73.7%
*-commutative73.7%
fma-neg73.7%
prod-diff73.7%
*-commutative73.7%
fma-neg73.7%
associate-+l+73.7%
*-commutative73.7%
fma-udef73.7%
distribute-lft-neg-in73.7%
*-commutative73.7%
distribute-rgt-neg-in73.7%
fma-def73.7%
*-commutative73.7%
fma-udef73.7%
distribute-lft-neg-in73.7%
*-commutative73.7%
distribute-rgt-neg-in73.7%
fma-def73.7%
Applied egg-rr73.7%
*-commutative73.7%
count-273.7%
*-commutative73.7%
Simplified73.7%
Taylor expanded in b_2 around 0 62.0%
mul-1-neg62.0%
distribute-lft1-in62.0%
metadata-eval62.0%
*-commutative62.0%
mul0-lft62.5%
metadata-eval62.5%
*-commutative62.5%
neg-sub062.5%
distribute-rgt-neg-out62.5%
Simplified62.5%
if 5.5e-42 < b_2 Initial program 70.2%
Taylor expanded in b_2 around inf 91.6%
Final simplification80.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ 1.0 (+ (* 0.5 (/ a b_2)) (* -2.0 (/ b_2 c)))) (+ (* -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-310) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} 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-310)) then
tmp = 1.0d0 / ((0.5d0 * (a / b_2)) + ((-2.0d0) * (b_2 / c)))
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-310) {
tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c)));
} 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-310: tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))) 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-310) tmp = Float64(1.0 / Float64(Float64(0.5 * Float64(a / b_2)) + Float64(-2.0 * Float64(b_2 / c)))); 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-310) tmp = 1.0 / ((0.5 * (a / b_2)) + (-2.0 * (b_2 / c))); 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-310], N[(1.0 / N[(N[(0.5 * N[(a / b$95$2), $MachinePrecision]), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{1}{0.5 \cdot \frac{a}{b_2} + -2 \cdot \frac{b_2}{c}}\\
\mathbf{else}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 33.9%
prod-diff33.7%
*-commutative33.7%
fma-neg33.7%
prod-diff33.7%
*-commutative33.7%
fma-neg33.7%
associate-+l+33.7%
*-commutative33.7%
fma-udef33.7%
distribute-lft-neg-in33.7%
*-commutative33.7%
distribute-rgt-neg-in33.7%
fma-def33.7%
*-commutative33.7%
fma-udef33.7%
distribute-lft-neg-in33.7%
*-commutative33.7%
distribute-rgt-neg-in33.7%
fma-def33.7%
Applied egg-rr33.7%
*-commutative33.7%
count-233.7%
*-commutative33.7%
Simplified33.7%
clear-num33.7%
inv-pow33.7%
+-commutative33.7%
*-commutative33.7%
fma-def33.7%
*-commutative33.7%
*-commutative33.7%
Applied egg-rr33.7%
unpow-133.7%
fma-udef33.7%
fma-def33.6%
*-commutative33.6%
neg-mul-133.6%
associate-*r*33.6%
*-commutative33.6%
distribute-lft1-in33.6%
metadata-eval33.6%
mul0-lft33.9%
metadata-eval33.9%
associate-+r-33.9%
Simplified33.9%
Taylor expanded in b_2 around -inf 68.0%
if -3.999999999999988e-310 < b_2 Initial program 73.0%
Taylor expanded in b_2 around inf 69.1%
Final simplification68.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-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 <= -4e-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 <= (-4d-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 <= -4e-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 <= -4e-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 <= -4e-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 <= -4e-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, -4e-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 -4 \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 < -3.999999999999988e-310Initial program 33.9%
Taylor expanded in b_2 around -inf 66.9%
associate-*r/66.9%
Simplified66.9%
if -3.999999999999988e-310 < b_2 Initial program 73.0%
Taylor expanded in b_2 around inf 69.1%
Final simplification68.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4e-310) (/ (* c -0.5) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4e-310) {
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 <= (-4d-310)) 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 <= -4e-310) {
tmp = (c * -0.5) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4e-310: 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 <= -4e-310) 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 <= -4e-310) 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, -4e-310], 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 -4 \cdot 10^{-310}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -3.999999999999988e-310Initial program 33.9%
Taylor expanded in b_2 around -inf 66.9%
associate-*r/66.9%
Simplified66.9%
if -3.999999999999988e-310 < b_2 Initial program 73.0%
Taylor expanded in b_2 around 0 38.2%
mul-1-neg38.2%
distribute-rgt-neg-out38.2%
Simplified38.2%
Taylor expanded in b_2 around inf 26.0%
associate-*r/26.0%
mul-1-neg26.0%
Simplified26.0%
Final simplification44.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -3e-309) (/ (* c -0.5) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3e-309) {
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 <= (-3d-309)) 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 <= -3e-309) {
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 <= -3e-309: 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 <= -3e-309) 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 <= -3e-309) 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, -3e-309], 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 -3 \cdot 10^{-309}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -3.000000000000001e-309Initial program 33.9%
Taylor expanded in b_2 around -inf 66.9%
associate-*r/66.9%
Simplified66.9%
if -3.000000000000001e-309 < b_2 Initial program 73.0%
Taylor expanded in b_2 around inf 68.6%
*-commutative68.6%
Simplified68.6%
Final simplification67.8%
(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 55.0%
Taylor expanded in b_2 around 0 32.8%
mul-1-neg32.8%
distribute-rgt-neg-out32.8%
Simplified32.8%
Taylor expanded in b_2 around inf 15.3%
associate-*r/15.3%
mul-1-neg15.3%
Simplified15.3%
Final simplification15.3%
herbie shell --seed 2023192
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))