
(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 12 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.4e-41)
(/ (* b_2 -2.0) a)
(if (<= b_2 3.7e-70)
(pow (/ a (- (hypot b_2 (sqrt (* a (- c)))) b_2)) -1.0)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-41) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 3.7e-70) {
tmp = pow((a / (hypot(b_2, sqrt((a * -c))) - b_2)), -1.0);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.4e-41) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 3.7e-70) {
tmp = Math.pow((a / (Math.hypot(b_2, Math.sqrt((a * -c))) - b_2)), -1.0);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.4e-41: tmp = (b_2 * -2.0) / a elif b_2 <= 3.7e-70: tmp = math.pow((a / (math.hypot(b_2, math.sqrt((a * -c))) - b_2)), -1.0) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.4e-41) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 3.7e-70) tmp = Float64(a / Float64(hypot(b_2, sqrt(Float64(a * Float64(-c)))) - b_2)) ^ -1.0; else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.4e-41) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 3.7e-70) tmp = (a / (hypot(b_2, sqrt((a * -c))) - b_2)) ^ -1.0; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.4e-41], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 3.7e-70], N[Power[N[(a / N[(N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b$95$2), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.4 \cdot 10^{-41}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 3.7 \cdot 10^{-70}:\\
\;\;\;\;{\left(\frac{a}{\mathsf{hypot}\left(b_2, \sqrt{a \cdot \left(-c\right)}\right) - b_2}\right)}^{-1}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.3999999999999998e-41Initial program 71.1%
+-commutative71.1%
unsub-neg71.1%
Simplified71.1%
Taylor expanded in b_2 around -inf 92.1%
*-commutative92.1%
Simplified92.1%
if -3.3999999999999998e-41 < b_2 < 3.7e-70Initial program 78.9%
+-commutative78.9%
unsub-neg78.9%
Simplified78.9%
clear-num78.7%
inv-pow78.7%
sub-neg78.7%
add-sqr-sqrt78.7%
hypot-def82.1%
*-commutative82.1%
distribute-rgt-neg-in82.1%
Applied egg-rr82.1%
if 3.7e-70 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification89.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.5e-41)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.32e-70)
(* (- (hypot b_2 (sqrt (* a (- c)))) b_2) (/ 1.0 a))
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-41) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.32e-70) {
tmp = (hypot(b_2, sqrt((a * -c))) - b_2) * (1.0 / a);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.5e-41) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.32e-70) {
tmp = (Math.hypot(b_2, Math.sqrt((a * -c))) - b_2) * (1.0 / a);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.5e-41: tmp = (b_2 * -2.0) / a elif b_2 <= 1.32e-70: tmp = (math.hypot(b_2, math.sqrt((a * -c))) - b_2) * (1.0 / a) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.5e-41) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.32e-70) tmp = Float64(Float64(hypot(b_2, sqrt(Float64(a * Float64(-c)))) - b_2) * Float64(1.0 / a)); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -3.5e-41) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.32e-70) tmp = (hypot(b_2, sqrt((a * -c))) - b_2) * (1.0 / a); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.5e-41], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.32e-70], N[(N[(N[Sqrt[b$95$2 ^ 2 + N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] - b$95$2), $MachinePrecision] * N[(1.0 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.5 \cdot 10^{-41}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.32 \cdot 10^{-70}:\\
\;\;\;\;\left(\mathsf{hypot}\left(b_2, \sqrt{a \cdot \left(-c\right)}\right) - b_2\right) \cdot \frac{1}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -3.5e-41Initial program 71.1%
+-commutative71.1%
unsub-neg71.1%
Simplified71.1%
Taylor expanded in b_2 around -inf 92.1%
*-commutative92.1%
Simplified92.1%
if -3.5e-41 < b_2 < 1.3200000000000001e-70Initial program 78.9%
+-commutative78.9%
unsub-neg78.9%
Simplified78.9%
clear-num78.7%
associate-/r/78.7%
sub-neg78.7%
add-sqr-sqrt78.7%
hypot-def82.1%
*-commutative82.1%
distribute-rgt-neg-in82.1%
Applied egg-rr82.1%
if 1.3200000000000001e-70 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification89.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.25e+117)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.12e-74)
(/ (- (sqrt (fma (- c) a (* b_2 b_2))) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.25e+117) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.12e-74) {
tmp = (sqrt(fma(-c, a, (b_2 * b_2))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.25e+117) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.12e-74) tmp = Float64(Float64(sqrt(fma(Float64(-c), a, Float64(b_2 * b_2))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.25e+117], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.12e-74], N[(N[(N[Sqrt[N[((-c) * a + N[(b$95$2 * b$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.25 \cdot 10^{+117}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.12 \cdot 10^{-74}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-c, a, b_2 \cdot b_2\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.24999999999999996e117Initial program 61.8%
+-commutative61.8%
unsub-neg61.8%
Simplified61.8%
Taylor expanded in b_2 around -inf 96.6%
*-commutative96.6%
Simplified96.6%
if -1.24999999999999996e117 < b_2 < 1.11999999999999999e-74Initial program 81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
sub-neg81.9%
+-commutative81.9%
*-commutative81.9%
distribute-lft-neg-in81.9%
fma-def81.9%
Applied egg-rr81.9%
if 1.11999999999999999e-74 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification88.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -7.8e+113)
(/ (* b_2 -2.0) a)
(if (<= b_2 1.65e-74)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.8e+113) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.65e-74) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / 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.8d+113)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.65d-74) then
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a
else
tmp = (c * (-0.5d0)) / 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.8e+113) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.65e-74) {
tmp = (Math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7.8e+113: tmp = (b_2 * -2.0) / a elif b_2 <= 1.65e-74: tmp = (math.sqrt(((b_2 * b_2) - (a * c))) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7.8e+113) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.65e-74) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7.8e+113) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.65e-74) tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7.8e+113], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.65e-74], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7.8 \cdot 10^{+113}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.65 \cdot 10^{-74}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -7.80000000000000039e113Initial program 61.8%
+-commutative61.8%
unsub-neg61.8%
Simplified61.8%
Taylor expanded in b_2 around -inf 96.6%
*-commutative96.6%
Simplified96.6%
if -7.80000000000000039e113 < b_2 < 1.64999999999999998e-74Initial program 81.9%
+-commutative81.9%
unsub-neg81.9%
Simplified81.9%
if 1.64999999999999998e-74 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification88.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -8e-76) (/ (* b_2 -2.0) a) (if (<= b_2 1.6e-75) (/ (- (sqrt (* a (- c))) b_2) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8e-76) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.6e-75) {
tmp = (sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / 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-76)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.6d-75) then
tmp = (sqrt((a * -c)) - b_2) / a
else
tmp = (c * (-0.5d0)) / 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-76) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.6e-75) {
tmp = (Math.sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -8e-76: tmp = (b_2 * -2.0) / a elif b_2 <= 1.6e-75: tmp = (math.sqrt((a * -c)) - b_2) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8e-76) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.6e-75) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -8e-76) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.6e-75) tmp = (sqrt((a * -c)) - b_2) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8e-76], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.6e-75], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8 \cdot 10^{-76}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-75}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -7.99999999999999942e-76Initial program 73.1%
+-commutative73.1%
unsub-neg73.1%
Simplified73.1%
Taylor expanded in b_2 around -inf 90.5%
*-commutative90.5%
Simplified90.5%
if -7.99999999999999942e-76 < b_2 < 1.59999999999999988e-75Initial program 77.0%
+-commutative77.0%
unsub-neg77.0%
Simplified77.0%
Taylor expanded in b_2 around 0 69.5%
associate-*r*69.5%
neg-mul-169.5%
*-commutative69.5%
Simplified69.5%
if 1.59999999999999988e-75 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification85.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.6e-96) (/ (* b_2 -2.0) a) (if (<= b_2 1.32e-77) (/ (sqrt (* a (- c))) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.6e-96) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.32e-77) {
tmp = sqrt((a * -c)) / a;
} else {
tmp = (c * -0.5) / 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.6d-96)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 1.32d-77) then
tmp = sqrt((a * -c)) / a
else
tmp = (c * (-0.5d0)) / 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.6e-96) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 1.32e-77) {
tmp = Math.sqrt((a * -c)) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.6e-96: tmp = (b_2 * -2.0) / a elif b_2 <= 1.32e-77: tmp = math.sqrt((a * -c)) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.6e-96) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 1.32e-77) tmp = Float64(sqrt(Float64(a * Float64(-c))) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -1.6e-96) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 1.32e-77) tmp = sqrt((a * -c)) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.6e-96], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 1.32e-77], N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.6 \cdot 10^{-96}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 1.32 \cdot 10^{-77}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.60000000000000006e-96Initial program 73.7%
+-commutative73.7%
unsub-neg73.7%
Simplified73.7%
Taylor expanded in b_2 around -inf 89.7%
*-commutative89.7%
Simplified89.7%
if -1.60000000000000006e-96 < b_2 < 1.31999999999999993e-77Initial program 76.3%
+-commutative76.3%
unsub-neg76.3%
Simplified76.3%
prod-diff75.9%
*-commutative75.9%
fma-def75.9%
associate-+l+75.9%
distribute-rgt-neg-in75.9%
fma-def75.8%
*-commutative75.8%
fma-udef75.9%
distribute-lft-neg-in75.9%
*-commutative75.9%
distribute-rgt-neg-in75.9%
fma-def75.8%
Applied egg-rr75.8%
Taylor expanded in b_2 around 0 67.8%
associate-*l/67.9%
*-lft-identity67.9%
distribute-lft1-in68.3%
metadata-eval68.3%
mul-1-neg68.3%
distribute-rgt-neg-out68.3%
Simplified68.3%
if 1.31999999999999993e-77 < b_2 Initial program 12.5%
+-commutative12.5%
unsub-neg12.5%
Simplified12.5%
Taylor expanded in b_2 around inf 91.5%
associate-*r/91.5%
Applied egg-rr91.5%
Final simplification85.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / 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 <= (-2d-310)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-310) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 73.1%
if -1.999999999999994e-310 < b_2 Initial program 26.4%
+-commutative26.4%
unsub-neg26.4%
Simplified26.4%
Taylor expanded in b_2 around inf 74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification74.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (- b_2) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = -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 <= (-2d-310)) then
tmp = -b_2 / a
else
tmp = (-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 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = -b_2 / a else: tmp = -0.5 * (c / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-b_2) / a); else tmp = 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 <= -2e-310) tmp = -b_2 / a; else tmp = -0.5 * (c / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[((-b$95$2) / a), $MachinePrecision], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around 0 40.6%
associate-*r*40.6%
neg-mul-140.6%
*-commutative40.6%
Simplified40.6%
Taylor expanded in c around 0 36.5%
associate-*r/36.5%
neg-mul-136.5%
Simplified36.5%
if -1.999999999999994e-310 < b_2 Initial program 26.4%
+-commutative26.4%
unsub-neg26.4%
Simplified26.4%
Taylor expanded in b_2 around inf 74.8%
Final simplification56.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (- b_2) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = (c * -0.5) / 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 <= (-2d-310)) then
tmp = -b_2 / a
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = -b_2 / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-310) tmp = -b_2 / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[((-b$95$2) / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around 0 40.6%
associate-*r*40.6%
neg-mul-140.6%
*-commutative40.6%
Simplified40.6%
Taylor expanded in c around 0 36.5%
associate-*r/36.5%
neg-mul-136.5%
Simplified36.5%
if -1.999999999999994e-310 < b_2 Initial program 26.4%
+-commutative26.4%
unsub-neg26.4%
Simplified26.4%
Taylor expanded in b_2 around inf 74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification56.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (* b_2 -2.0) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / 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 <= (-2d-310)) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = (c * (-0.5d0)) / b_2
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = (b_2 * -2.0) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-310) tmp = (b_2 * -2.0) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around -inf 72.9%
*-commutative72.9%
Simplified72.9%
if -1.999999999999994e-310 < b_2 Initial program 26.4%
+-commutative26.4%
unsub-neg26.4%
Simplified26.4%
Taylor expanded in b_2 around inf 74.8%
associate-*r/74.8%
Applied egg-rr74.8%
Final simplification73.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (- b_2) a) (/ 0.0 a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = 0.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 <= (-2d-310)) then
tmp = -b_2 / a
else
tmp = 0.0d0 / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = -b_2 / a else: tmp = 0.0 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(0.0 / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2e-310) tmp = -b_2 / a; else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[((-b$95$2) / a), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
Taylor expanded in b_2 around 0 40.6%
associate-*r*40.6%
neg-mul-140.6%
*-commutative40.6%
Simplified40.6%
Taylor expanded in c around 0 36.5%
associate-*r/36.5%
neg-mul-136.5%
Simplified36.5%
if -1.999999999999994e-310 < b_2 Initial program 26.4%
+-commutative26.4%
unsub-neg26.4%
Simplified26.4%
add-sqr-sqrt23.1%
pow223.1%
pow1/223.1%
sqrt-pow123.0%
fma-neg23.1%
*-commutative23.1%
distribute-rgt-neg-in23.1%
metadata-eval23.1%
Applied egg-rr23.1%
Taylor expanded in b_2 around inf 21.1%
distribute-rgt1-in21.1%
metadata-eval21.1%
mul0-lft21.1%
Simplified21.1%
Final simplification28.5%
(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 50.2%
+-commutative50.2%
unsub-neg50.2%
Simplified50.2%
add-sqr-sqrt48.4%
pow248.4%
pow1/248.4%
sqrt-pow148.3%
fma-neg48.4%
*-commutative48.4%
distribute-rgt-neg-in48.4%
metadata-eval48.4%
Applied egg-rr48.4%
Taylor expanded in b_2 around inf 12.1%
distribute-rgt1-in12.1%
metadata-eval12.1%
mul0-lft12.1%
Simplified12.1%
Final simplification12.1%
herbie shell --seed 2023275
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))