
(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 11 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 (* c (- a)))) 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((c * -a))) - 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((c * -a))) - 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((c * -a))) - 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(c * Float64(-a)))) - 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((c * -a))) - 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[(c * (-a)), $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{c \cdot \left(-a\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 (* c (- a)))) 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((c * -a))) - 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((c * -a))) - 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((c * -a))) - 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(c * Float64(-a)))) - 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((c * -a))) - 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[(c * (-a)), $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{c \cdot \left(-a\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 (* c (- a))) 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((c * -a)) - 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((c * -a)) - 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((c * -a)) - 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((c * -a)) - 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(c * Float64(-a))) - 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((c * -a)) - 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[(c * (-a)), $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{c \cdot \left(-a\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%
mul-1-neg69.5%
distribute-rgt-neg-out69.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 -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 2.3e-308) (/ (- b_2) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 2.3e-308) {
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 <= 2.3d-308) 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 <= 2.3e-308) {
tmp = -b_2 / a;
} else {
tmp = -0.5 * (c / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 2.3e-308: 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 <= 2.3e-308) 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 <= 2.3e-308) 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, 2.3e-308], 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.3 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < 2.2999999999999999e-308Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
div-sub75.5%
add-sqr-sqrt75.3%
*-un-lft-identity75.3%
times-frac75.3%
fma-neg75.4%
Applied egg-rr75.4%
Taylor expanded in b_2 around inf 36.5%
associate-*r/36.5%
neg-mul-136.5%
Simplified36.5%
if 2.2999999999999999e-308 < 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%
div-sub75.5%
add-sqr-sqrt75.3%
*-un-lft-identity75.3%
times-frac75.3%
fma-neg75.4%
Applied egg-rr75.4%
Taylor expanded in b_2 around inf 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))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = -b_2 / a;
} else {
tmp = 0.0;
}
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
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;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = -b_2 / a else: tmp = 0.0 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-b_2) / a); else tmp = 0.0; 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; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[((-b$95$2) / a), $MachinePrecision], 0.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 75.5%
+-commutative75.5%
unsub-neg75.5%
Simplified75.5%
div-sub75.5%
add-sqr-sqrt75.3%
*-un-lft-identity75.3%
times-frac75.3%
fma-neg75.4%
Applied egg-rr75.4%
Taylor expanded in b_2 around inf 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%
div-sub25.3%
add-sqr-sqrt22.8%
*-un-lft-identity22.8%
times-frac23.5%
fma-neg22.2%
Applied egg-rr22.2%
Taylor expanded in b_2 around inf 14.5%
distribute-rgt1-in14.5%
metadata-eval14.5%
mul0-lft21.1%
Simplified21.1%
Final simplification28.5%
(FPCore (a b_2 c) :precision binary64 0.0)
double code(double a, double b_2, double c) {
return 0.0;
}
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
end function
public static double code(double a, double b_2, double c) {
return 0.0;
}
def code(a, b_2, c): return 0.0
function code(a, b_2, c) return 0.0 end
function tmp = code(a, b_2, c) tmp = 0.0; end
code[a_, b$95$2_, c_] := 0.0
\begin{array}{l}
\\
0
\end{array}
Initial program 50.2%
+-commutative50.2%
unsub-neg50.2%
Simplified50.2%
div-sub49.6%
add-sqr-sqrt48.2%
*-un-lft-identity48.2%
times-frac48.6%
fma-neg47.9%
Applied egg-rr48.0%
Taylor expanded in b_2 around inf 8.5%
distribute-rgt1-in8.5%
metadata-eval8.5%
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))