
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.3e+137)
(/ (* b_2 -2.0) a)
(if (<= b_2 2.8e+15)
(/ (- (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 <= -2.3e+137) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.8e+15) {
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 <= (-2.3d+137)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 2.8d+15) 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 <= -2.3e+137) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.8e+15) {
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 <= -2.3e+137: tmp = (b_2 * -2.0) / a elif b_2 <= 2.8e+15: 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 <= -2.3e+137) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 2.8e+15) 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 <= -2.3e+137) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 2.8e+15) 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, -2.3e+137], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.8e+15], 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 -2.3 \cdot 10^{+137}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 2.8 \cdot 10^{+15}:\\
\;\;\;\;\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 < -2.29999999999999999e137Initial program 50.0%
+-commutative50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in b_2 around -inf 95.2%
*-commutative95.2%
Simplified95.2%
if -2.29999999999999999e137 < b_2 < 2.8e15Initial program 78.5%
+-commutative78.5%
unsub-neg78.5%
Simplified78.5%
if 2.8e15 < b_2 Initial program 12.1%
+-commutative12.1%
unsub-neg12.1%
Simplified12.1%
clear-num12.1%
associate-/r/12.1%
sub-neg12.1%
add-sqr-sqrt7.9%
hypot-def25.8%
*-commutative25.8%
distribute-rgt-neg-in25.8%
Applied egg-rr25.8%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.8%
associate-*r*92.8%
metadata-eval92.8%
Simplified92.8%
Final simplification84.5%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.8e-49)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 -5.8e-95)
(/ (sqrt (* c (/ a -1.0))) a)
(if (<= b_2 -4e-136)
(/ (* b_2 -2.0) a)
(if (<= b_2 2.4e+15)
(/ (- (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 <= -2.8e-49) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= -5.8e-95) {
tmp = sqrt((c * (a / -1.0))) / a;
} else if (b_2 <= -4e-136) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.4e+15) {
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 <= (-2.8d-49)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= (-5.8d-95)) then
tmp = sqrt((c * (a / (-1.0d0)))) / a
else if (b_2 <= (-4d-136)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 2.4d+15) 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 <= -2.8e-49) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= -5.8e-95) {
tmp = Math.sqrt((c * (a / -1.0))) / a;
} else if (b_2 <= -4e-136) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.4e+15) {
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 <= -2.8e-49: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= -5.8e-95: tmp = math.sqrt((c * (a / -1.0))) / a elif b_2 <= -4e-136: tmp = (b_2 * -2.0) / a elif b_2 <= 2.4e+15: 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 <= -2.8e-49) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= -5.8e-95) tmp = Float64(sqrt(Float64(c * Float64(a / -1.0))) / a); elseif (b_2 <= -4e-136) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 2.4e+15) 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 <= -2.8e-49) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= -5.8e-95) tmp = sqrt((c * (a / -1.0))) / a; elseif (b_2 <= -4e-136) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 2.4e+15) 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, -2.8e-49], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -5.8e-95], N[(N[Sqrt[N[(c * N[(a / -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, -4e-136], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.4e+15], 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 -2.8 \cdot 10^{-49}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq -5.8 \cdot 10^{-95}:\\
\;\;\;\;\frac{\sqrt{c \cdot \frac{a}{-1}}}{a}\\
\mathbf{elif}\;b_2 \leq -4 \cdot 10^{-136}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 2.4 \cdot 10^{+15}:\\
\;\;\;\;\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 < -2.79999999999999997e-49Initial program 75.0%
+-commutative75.0%
unsub-neg75.0%
Simplified75.0%
Taylor expanded in b_2 around -inf 86.3%
if -2.79999999999999997e-49 < b_2 < -5.80000000000000004e-95Initial program 99.8%
+-commutative99.8%
unsub-neg99.8%
Simplified99.8%
add-sqr-sqrt99.0%
pow299.0%
pow1/299.0%
sqrt-pow199.1%
fma-neg99.1%
*-commutative99.1%
distribute-rgt-neg-in99.1%
metadata-eval99.1%
Applied egg-rr99.1%
Taylor expanded in c around -inf 27.0%
unpow227.0%
exp-prod25.3%
exp-prod24.9%
pow-sqr24.9%
+-commutative24.9%
mul-1-neg24.9%
unsub-neg24.9%
Simplified24.9%
Taylor expanded in b_2 around 0 27.0%
log-div94.6%
*-commutative94.6%
exp-to-pow99.8%
unpow1/299.8%
associate-/r/99.8%
Simplified99.8%
if -5.80000000000000004e-95 < b_2 < -4.00000000000000001e-136Initial program 78.4%
+-commutative78.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in b_2 around -inf 78.6%
*-commutative78.6%
Simplified78.6%
if -4.00000000000000001e-136 < b_2 < 2.4e15Initial program 68.0%
+-commutative68.0%
unsub-neg68.0%
Simplified68.0%
Taylor expanded in b_2 around 0 67.2%
mul-1-neg67.2%
distribute-rgt-neg-out67.2%
Simplified67.2%
if 2.4e15 < b_2 Initial program 12.1%
+-commutative12.1%
unsub-neg12.1%
Simplified12.1%
clear-num12.1%
associate-/r/12.1%
sub-neg12.1%
add-sqr-sqrt7.9%
hypot-def25.8%
*-commutative25.8%
distribute-rgt-neg-in25.8%
Applied egg-rr25.8%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.8%
associate-*r*92.8%
metadata-eval92.8%
Simplified92.8%
Final simplification81.4%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (/ (sqrt (* c (/ a -1.0))) a)))
(if (<= b_2 -2.7e-49)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 -2.6e-90)
t_0
(if (<= b_2 -4e-136)
(/ (* b_2 -2.0) a)
(if (<= b_2 2.4e+15) t_0 (/ (* c -0.5) b_2)))))))
double code(double a, double b_2, double c) {
double t_0 = sqrt((c * (a / -1.0))) / a;
double tmp;
if (b_2 <= -2.7e-49) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= -2.6e-90) {
tmp = t_0;
} else if (b_2 <= -4e-136) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.4e+15) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = sqrt((c * (a / (-1.0d0)))) / a
if (b_2 <= (-2.7d-49)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= (-2.6d-90)) then
tmp = t_0
else if (b_2 <= (-4d-136)) then
tmp = (b_2 * (-2.0d0)) / a
else if (b_2 <= 2.4d+15) then
tmp = t_0
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 t_0 = Math.sqrt((c * (a / -1.0))) / a;
double tmp;
if (b_2 <= -2.7e-49) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= -2.6e-90) {
tmp = t_0;
} else if (b_2 <= -4e-136) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 2.4e+15) {
tmp = t_0;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): t_0 = math.sqrt((c * (a / -1.0))) / a tmp = 0 if b_2 <= -2.7e-49: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= -2.6e-90: tmp = t_0 elif b_2 <= -4e-136: tmp = (b_2 * -2.0) / a elif b_2 <= 2.4e+15: tmp = t_0 else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) t_0 = Float64(sqrt(Float64(c * Float64(a / -1.0))) / a) tmp = 0.0 if (b_2 <= -2.7e-49) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= -2.6e-90) tmp = t_0; elseif (b_2 <= -4e-136) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 2.4e+15) tmp = t_0; else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
function tmp_2 = code(a, b_2, c) t_0 = sqrt((c * (a / -1.0))) / a; tmp = 0.0; if (b_2 <= -2.7e-49) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= -2.6e-90) tmp = t_0; elseif (b_2 <= -4e-136) tmp = (b_2 * -2.0) / a; elseif (b_2 <= 2.4e+15) tmp = t_0; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[(c * N[(a / -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]}, If[LessEqual[b$95$2, -2.7e-49], N[(N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, -2.6e-90], t$95$0, If[LessEqual[b$95$2, -4e-136], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.4e+15], t$95$0, N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\sqrt{c \cdot \frac{a}{-1}}}{a}\\
\mathbf{if}\;b_2 \leq -2.7 \cdot 10^{-49}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq -2.6 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b_2 \leq -4 \cdot 10^{-136}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 2.4 \cdot 10^{+15}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -2.7e-49Initial program 75.0%
+-commutative75.0%
unsub-neg75.0%
Simplified75.0%
Taylor expanded in b_2 around -inf 86.3%
if -2.7e-49 < b_2 < -2.6e-90 or -4.00000000000000001e-136 < b_2 < 2.4e15Initial program 70.3%
+-commutative70.3%
unsub-neg70.3%
Simplified70.3%
add-sqr-sqrt70.0%
pow270.0%
pow1/270.0%
sqrt-pow170.2%
fma-neg70.2%
*-commutative70.2%
distribute-rgt-neg-in70.2%
metadata-eval70.2%
Applied egg-rr70.2%
Taylor expanded in c around -inf 34.7%
unpow234.7%
exp-prod33.9%
exp-prod33.4%
pow-sqr33.4%
+-commutative33.4%
mul-1-neg33.4%
unsub-neg33.4%
Simplified33.4%
Taylor expanded in b_2 around 0 34.5%
log-div64.7%
*-commutative64.7%
exp-to-pow69.0%
unpow1/269.0%
associate-/r/69.0%
Simplified69.0%
if -2.6e-90 < b_2 < -4.00000000000000001e-136Initial program 78.4%
+-commutative78.4%
unsub-neg78.4%
Simplified78.4%
Taylor expanded in b_2 around -inf 78.6%
*-commutative78.6%
Simplified78.6%
if 2.4e15 < b_2 Initial program 12.1%
+-commutative12.1%
unsub-neg12.1%
Simplified12.1%
clear-num12.1%
associate-/r/12.1%
sub-neg12.1%
add-sqr-sqrt7.9%
hypot-def25.8%
*-commutative25.8%
distribute-rgt-neg-in25.8%
Applied egg-rr25.8%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt92.8%
associate-*r*92.8%
metadata-eval92.8%
Simplified92.8%
Final simplification81.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-311) (+ (* -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-311) {
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-311)) 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-311) {
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-311: 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-311) 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-311) 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-311], 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^{-311}:\\
\;\;\;\;-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.9999999999999e-311Initial program 74.8%
+-commutative74.8%
unsub-neg74.8%
Simplified74.8%
Taylor expanded in b_2 around -inf 66.3%
if -1.9999999999999e-311 < b_2 Initial program 40.3%
+-commutative40.3%
unsub-neg40.3%
Simplified40.3%
clear-num40.3%
associate-/r/40.2%
sub-neg40.2%
add-sqr-sqrt38.1%
hypot-def47.1%
*-commutative47.1%
distribute-rgt-neg-in47.1%
Applied egg-rr47.1%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.6%
associate-*r*57.6%
metadata-eval57.6%
Simplified57.6%
Final simplification62.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-311) (/ (- b_2) a) (* -0.5 (/ c b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
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-311)) 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-311) {
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-311: 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-311) 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-311) 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-311], 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^{-311}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.9999999999999e-311Initial program 74.8%
+-commutative74.8%
unsub-neg74.8%
Simplified74.8%
add-sqr-sqrt74.5%
pow274.5%
pow1/274.5%
sqrt-pow174.6%
fma-neg74.6%
*-commutative74.6%
distribute-rgt-neg-in74.6%
metadata-eval74.6%
Applied egg-rr74.6%
Taylor expanded in b_2 around inf 27.2%
associate-*r/27.2%
neg-mul-127.2%
Simplified27.2%
if -1.9999999999999e-311 < b_2 Initial program 40.3%
+-commutative40.3%
unsub-neg40.3%
Simplified40.3%
Taylor expanded in b_2 around inf 57.5%
Final simplification42.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-311) (/ (- b_2) a) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-311) {
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-311)) 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-311) {
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-311: 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-311) 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-311) 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-311], 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^{-311}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.9999999999999e-311Initial program 74.8%
+-commutative74.8%
unsub-neg74.8%
Simplified74.8%
add-sqr-sqrt74.5%
pow274.5%
pow1/274.5%
sqrt-pow174.6%
fma-neg74.6%
*-commutative74.6%
distribute-rgt-neg-in74.6%
metadata-eval74.6%
Applied egg-rr74.6%
Taylor expanded in b_2 around inf 27.2%
associate-*r/27.2%
neg-mul-127.2%
Simplified27.2%
if -1.9999999999999e-311 < b_2 Initial program 40.3%
+-commutative40.3%
unsub-neg40.3%
Simplified40.3%
clear-num40.3%
associate-/r/40.2%
sub-neg40.2%
add-sqr-sqrt38.1%
hypot-def47.1%
*-commutative47.1%
distribute-rgt-neg-in47.1%
Applied egg-rr47.1%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.6%
associate-*r*57.6%
metadata-eval57.6%
Simplified57.6%
Final simplification42.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 2e-309) (/ (* 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-309) {
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-309) 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-309) {
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-309: 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-309) 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-309) 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-309], 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^{-309}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < 1.9999999999999988e-309Initial program 74.8%
+-commutative74.8%
unsub-neg74.8%
Simplified74.8%
Taylor expanded in b_2 around -inf 66.1%
*-commutative66.1%
Simplified66.1%
if 1.9999999999999988e-309 < b_2 Initial program 40.3%
+-commutative40.3%
unsub-neg40.3%
Simplified40.3%
clear-num40.3%
associate-/r/40.2%
sub-neg40.2%
add-sqr-sqrt38.1%
hypot-def47.1%
*-commutative47.1%
distribute-rgt-neg-in47.1%
Applied egg-rr47.1%
Taylor expanded in b_2 around inf 0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt57.6%
associate-*r*57.6%
metadata-eval57.6%
Simplified57.6%
Final simplification61.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.2e-299) (/ (- b_2) a) (/ 0.0 a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.2e-299) {
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 <= (-2.2d-299)) 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 <= -2.2e-299) {
tmp = -b_2 / a;
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.2e-299: tmp = -b_2 / a else: tmp = 0.0 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.2e-299) 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 <= -2.2e-299) 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, -2.2e-299], N[((-b$95$2) / a), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.2 \cdot 10^{-299}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b_2 < -2.2e-299Initial program 74.4%
+-commutative74.4%
unsub-neg74.4%
Simplified74.4%
add-sqr-sqrt74.1%
pow274.1%
pow1/274.1%
sqrt-pow174.2%
fma-neg74.2%
*-commutative74.2%
distribute-rgt-neg-in74.2%
metadata-eval74.2%
Applied egg-rr74.2%
Taylor expanded in b_2 around inf 27.6%
associate-*r/27.6%
neg-mul-127.6%
Simplified27.6%
if -2.2e-299 < b_2 Initial program 41.2%
+-commutative41.2%
unsub-neg41.2%
Simplified41.2%
add-sqr-sqrt38.7%
pow238.7%
pow1/238.7%
sqrt-pow138.8%
fma-neg38.8%
*-commutative38.8%
distribute-rgt-neg-in38.8%
metadata-eval38.8%
Applied egg-rr38.8%
Taylor expanded in b_2 around inf 16.3%
distribute-lft1-in16.3%
metadata-eval16.3%
mul0-lft16.3%
Simplified16.3%
Final simplification21.9%
(FPCore (a b_2 c) :precision binary64 (/ 0.0 a))
double code(double a, double b_2, double c) {
return 0.0 / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = 0.0d0 / a
end function
public static double code(double a, double b_2, double c) {
return 0.0 / a;
}
def code(a, b_2, c): return 0.0 / a
function code(a, b_2, c) return Float64(0.0 / a) end
function tmp = code(a, b_2, c) tmp = 0.0 / a; end
code[a_, b$95$2_, c_] := N[(0.0 / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{0}{a}
\end{array}
Initial program 57.7%
+-commutative57.7%
unsub-neg57.7%
Simplified57.7%
add-sqr-sqrt56.3%
pow256.3%
pow1/256.3%
sqrt-pow156.4%
fma-neg56.4%
*-commutative56.4%
distribute-rgt-neg-in56.4%
metadata-eval56.4%
Applied egg-rr56.4%
Taylor expanded in b_2 around inf 9.5%
distribute-lft1-in9.5%
metadata-eval9.5%
mul0-lft9.5%
Simplified9.5%
Final simplification9.5%
herbie shell --seed 2023258
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))