
(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 8 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 -6e-70)
(/ (* -0.5 c) b_2)
(if (<= b_2 2e+98)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6e-70) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2e+98) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} 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 <= (-6d-70)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 2d+98) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
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 <= -6e-70) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2e+98) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6e-70: tmp = (-0.5 * c) / b_2 elif b_2 <= 2e+98: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6e-70) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 2e+98) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); 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 <= -6e-70) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 2e+98) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6e-70], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2e+98], N[(N[((-b$95$2) - N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6 \cdot 10^{-70}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -6.0000000000000003e-70Initial program 15.0%
Taylor expanded in b_2 around -inf 88.8%
associate-*r/88.8%
Applied egg-rr88.8%
if -6.0000000000000003e-70 < b_2 < 2e98Initial program 75.6%
if 2e98 < b_2 Initial program 61.6%
Taylor expanded in b_2 around inf 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification85.1%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -3.2e-65)
(/ (* -0.5 c) b_2)
(if (<= b_2 1e-11)
(/ (- (- b_2) (sqrt (* a (- c)))) a)
(/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -3.2e-65) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1e-11) {
tmp = (-b_2 - sqrt((a * -c))) / a;
} 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 <= (-3.2d-65)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1d-11) then
tmp = (-b_2 - sqrt((a * -c))) / a
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 <= -3.2e-65) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1e-11) {
tmp = (-b_2 - Math.sqrt((a * -c))) / a;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -3.2e-65: tmp = (-0.5 * c) / b_2 elif b_2 <= 1e-11: tmp = (-b_2 - math.sqrt((a * -c))) / a else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -3.2e-65) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1e-11) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(a * Float64(-c)))) / a); 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 <= -3.2e-65) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1e-11) tmp = (-b_2 - sqrt((a * -c))) / a; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -3.2e-65], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1e-11], N[(N[((-b$95$2) - N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.2 \cdot 10^{-65}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 10^{-11}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -3.1999999999999999e-65Initial program 15.0%
Taylor expanded in b_2 around -inf 88.8%
associate-*r/88.8%
Applied egg-rr88.8%
if -3.1999999999999999e-65 < b_2 < 9.99999999999999939e-12Initial program 72.8%
Taylor expanded in b_2 around 0 62.8%
associate-*r*62.8%
neg-mul-162.8%
*-commutative62.8%
Simplified62.8%
if 9.99999999999999939e-12 < b_2 Initial program 69.7%
Taylor expanded in b_2 around inf 89.6%
*-commutative89.6%
Simplified89.6%
Final simplification80.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.15e-67) (/ (* -0.5 c) b_2) (if (<= b_2 1e-11) (/ (- (sqrt (* a (- c)))) a) (/ (* b_2 -2.0) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.15e-67) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1e-11) {
tmp = -sqrt((a * -c)) / a;
} 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 <= (-1.15d-67)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1d-11) then
tmp = -sqrt((a * -c)) / a
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 <= -1.15e-67) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1e-11) {
tmp = -Math.sqrt((a * -c)) / a;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.15e-67: tmp = (-0.5 * c) / b_2 elif b_2 <= 1e-11: tmp = -math.sqrt((a * -c)) / a else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.15e-67) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1e-11) tmp = Float64(Float64(-sqrt(Float64(a * Float64(-c)))) / a); 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 <= -1.15e-67) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1e-11) tmp = -sqrt((a * -c)) / a; else tmp = (b_2 * -2.0) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.15e-67], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1e-11], N[((-N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision]) / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.15 \cdot 10^{-67}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 10^{-11}:\\
\;\;\;\;\frac{-\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -1.15e-67Initial program 15.0%
Taylor expanded in b_2 around -inf 88.8%
associate-*r/88.8%
Applied egg-rr88.8%
if -1.15e-67 < b_2 < 9.99999999999999939e-12Initial program 72.8%
prod-diff72.3%
*-commutative72.3%
fma-neg72.3%
prod-diff72.3%
*-commutative72.3%
fma-neg72.3%
associate-+l+72.3%
*-commutative72.3%
fma-udef72.3%
distribute-lft-neg-in72.3%
*-commutative72.3%
distribute-rgt-neg-in72.3%
fma-def72.3%
*-commutative72.3%
fma-udef72.3%
distribute-lft-neg-in72.3%
*-commutative72.3%
distribute-rgt-neg-in72.3%
fma-def72.3%
Applied egg-rr72.3%
count-272.3%
Simplified72.3%
Taylor expanded in b_2 around 0 60.4%
mul-1-neg60.4%
distribute-lft1-in60.4%
metadata-eval60.4%
mul0-lft60.9%
metadata-eval60.9%
neg-sub060.9%
distribute-rgt-neg-out60.9%
Simplified60.9%
if 9.99999999999999939e-12 < b_2 Initial program 69.7%
Taylor expanded in b_2 around inf 89.6%
*-commutative89.6%
Simplified89.6%
Final simplification79.6%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.9e-237) (* -0.5 (/ c b_2)) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.9e-237) {
tmp = -0.5 * (c / 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 <= (-1.9d-237)) then
tmp = (-0.5d0) * (c / 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 <= -1.9e-237) {
tmp = -0.5 * (c / b_2);
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.9e-237: tmp = -0.5 * (c / b_2) else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.9e-237) tmp = Float64(-0.5 * Float64(c / 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 <= -1.9e-237) tmp = -0.5 * (c / b_2); else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.9e-237], N[(-0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\
\;\;\;\;-0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.90000000000000012e-237Initial program 26.8%
Taylor expanded in b_2 around -inf 73.8%
if -1.90000000000000012e-237 < b_2 Initial program 72.2%
add-sqr-sqrt72.0%
pow272.0%
pow1/272.0%
sqrt-pow172.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b_2 around inf 30.0%
neg-mul-130.0%
Simplified30.0%
Final simplification49.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.9e-237) (/ (* -0.5 c) b_2) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.9e-237) {
tmp = (-0.5 * c) / 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 <= (-1.9d-237)) then
tmp = ((-0.5d0) * c) / 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 <= -1.9e-237) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.9e-237: tmp = (-0.5 * c) / b_2 else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.9e-237) tmp = Float64(Float64(-0.5 * c) / 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 <= -1.9e-237) tmp = (-0.5 * c) / b_2; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.9e-237], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.9 \cdot 10^{-237}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -1.90000000000000012e-237Initial program 26.8%
Taylor expanded in b_2 around -inf 73.8%
associate-*r/73.8%
Applied egg-rr73.8%
if -1.90000000000000012e-237 < b_2 Initial program 72.2%
add-sqr-sqrt72.0%
pow272.0%
pow1/272.0%
sqrt-pow172.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b_2 around inf 30.0%
neg-mul-130.0%
Simplified30.0%
Final simplification49.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.9e-237) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.9e-237) {
tmp = (-0.5 * c) / 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 <= (-1.9d-237)) then
tmp = ((-0.5d0) * c) / 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 <= -1.9e-237) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -1.9e-237: tmp = (-0.5 * c) / b_2 else: tmp = (b_2 * -2.0) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.9e-237) tmp = Float64(Float64(-0.5 * c) / 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 <= -1.9e-237) tmp = (-0.5 * c) / 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, -1.9e-237], N[(N[(-0.5 * c), $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 -1.9 \cdot 10^{-237}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -1.90000000000000012e-237Initial program 26.8%
Taylor expanded in b_2 around -inf 73.8%
associate-*r/73.8%
Applied egg-rr73.8%
if -1.90000000000000012e-237 < b_2 Initial program 72.2%
Taylor expanded in b_2 around inf 60.7%
*-commutative60.7%
Simplified60.7%
Final simplification66.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.02e-237) (/ 0.0 a) (/ (- b_2) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.02e-237) {
tmp = 0.0 / a;
} 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 <= (-2.02d-237)) then
tmp = 0.0d0 / a
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 <= -2.02e-237) {
tmp = 0.0 / a;
} else {
tmp = -b_2 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.02e-237: tmp = 0.0 / a else: tmp = -b_2 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.02e-237) tmp = Float64(0.0 / a); 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 <= -2.02e-237) tmp = 0.0 / a; else tmp = -b_2 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.02e-237], N[(0.0 / a), $MachinePrecision], N[((-b$95$2) / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.02 \cdot 10^{-237}:\\
\;\;\;\;\frac{0}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-b_2}{a}\\
\end{array}
\end{array}
if b_2 < -2.02e-237Initial program 26.8%
add-sqr-sqrt25.2%
pow225.2%
pow1/225.2%
sqrt-pow125.3%
metadata-eval25.3%
Applied egg-rr25.3%
Taylor expanded in b_2 around -inf 21.2%
distribute-rgt1-in21.2%
metadata-eval21.2%
mul0-lft21.2%
Simplified21.2%
if -2.02e-237 < b_2 Initial program 72.2%
add-sqr-sqrt72.0%
pow272.0%
pow1/272.0%
sqrt-pow172.0%
metadata-eval72.0%
Applied egg-rr72.0%
Taylor expanded in b_2 around inf 30.0%
neg-mul-130.0%
Simplified30.0%
Final simplification26.2%
(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 52.2%
add-sqr-sqrt51.4%
pow251.4%
pow1/251.4%
sqrt-pow151.4%
metadata-eval51.4%
Applied egg-rr51.4%
Taylor expanded in b_2 around -inf 10.8%
distribute-rgt1-in10.8%
metadata-eval10.8%
mul0-lft10.8%
Simplified10.8%
Final simplification10.8%
(FPCore (a b_2 c)
:precision binary64
(let* ((t_0 (* (sqrt (fabs a)) (sqrt (fabs c))))
(t_1
(if (== (copysign a c) a)
(if (> (fabs b_2) t_0)
(* (sqrt (- (fabs b_2) t_0)) (sqrt (+ (fabs b_2) t_0)))
NAN)
(hypot b_2 t_0))))
(if (< b_2 0.0) (/ c (- t_1 (/ b_2 2.0))) (/ (+ (/ b_2 2.0) t_1) (- a)))))
double code(double a, double b_2, double c) {
double t_0 = sqrt(fabs(a)) * sqrt(fabs(c));
double tmp_1;
if (copysign(a, c) == a) {
double tmp_2;
if (fabs(b_2) > t_0) {
tmp_2 = sqrt((fabs(b_2) - t_0)) * sqrt((fabs(b_2) + t_0));
} else {
tmp_2 = (double) NAN;
}
tmp_1 = tmp_2;
} else {
tmp_1 = hypot(b_2, t_0);
}
double t_1 = tmp_1;
double tmp_3;
if (b_2 < 0.0) {
tmp_3 = c / (t_1 - (b_2 / 2.0));
} else {
tmp_3 = ((b_2 / 2.0) + t_1) / -a;
}
return tmp_3;
}
public static double code(double a, double b_2, double c) {
double t_0 = Math.sqrt(Math.abs(a)) * Math.sqrt(Math.abs(c));
double tmp_1;
if (Math.copySign(a, c) == a) {
double tmp_2;
if (Math.abs(b_2) > t_0) {
tmp_2 = Math.sqrt((Math.abs(b_2) - t_0)) * Math.sqrt((Math.abs(b_2) + t_0));
} else {
tmp_2 = Double.NaN;
}
tmp_1 = tmp_2;
} else {
tmp_1 = Math.hypot(b_2, t_0);
}
double t_1 = tmp_1;
double tmp_3;
if (b_2 < 0.0) {
tmp_3 = c / (t_1 - (b_2 / 2.0));
} else {
tmp_3 = ((b_2 / 2.0) + t_1) / -a;
}
return tmp_3;
}
def code(a, b_2, c): t_0 = math.sqrt(math.fabs(a)) * math.sqrt(math.fabs(c)) tmp_1 = 0 if math.copysign(a, c) == a: tmp_2 = 0 if math.fabs(b_2) > t_0: tmp_2 = math.sqrt((math.fabs(b_2) - t_0)) * math.sqrt((math.fabs(b_2) + t_0)) else: tmp_2 = math.nan tmp_1 = tmp_2 else: tmp_1 = math.hypot(b_2, t_0) t_1 = tmp_1 tmp_3 = 0 if b_2 < 0.0: tmp_3 = c / (t_1 - (b_2 / 2.0)) else: tmp_3 = ((b_2 / 2.0) + t_1) / -a return tmp_3
function code(a, b_2, c) t_0 = Float64(sqrt(abs(a)) * sqrt(abs(c))) tmp_1 = 0.0 if (copysign(a, c) == a) tmp_2 = 0.0 if (abs(b_2) > t_0) tmp_2 = Float64(sqrt(Float64(abs(b_2) - t_0)) * sqrt(Float64(abs(b_2) + t_0))); else tmp_2 = NaN; end tmp_1 = tmp_2; else tmp_1 = hypot(b_2, t_0); end t_1 = tmp_1 tmp_3 = 0.0 if (b_2 < 0.0) tmp_3 = Float64(c / Float64(t_1 - Float64(b_2 / 2.0))); else tmp_3 = Float64(Float64(Float64(b_2 / 2.0) + t_1) / Float64(-a)); end return tmp_3 end
function tmp_5 = code(a, b_2, c) t_0 = sqrt(abs(a)) * sqrt(abs(c)); tmp_2 = 0.0; if ((sign(c) * abs(a)) == a) tmp_3 = 0.0; if (abs(b_2) > t_0) tmp_3 = sqrt((abs(b_2) - t_0)) * sqrt((abs(b_2) + t_0)); else tmp_3 = NaN; end tmp_2 = tmp_3; else tmp_2 = hypot(b_2, t_0); end t_1 = tmp_2; tmp_4 = 0.0; if (b_2 < 0.0) tmp_4 = c / (t_1 - (b_2 / 2.0)); else tmp_4 = ((b_2 / 2.0) + t_1) / -a; end tmp_5 = tmp_4; end
code[a_, b$95$2_, c_] := Block[{t$95$0 = N[(N[Sqrt[N[Abs[a], $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Abs[c], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = If[Equal[N[With[{TMP1 = Abs[a], TMP2 = Sign[c]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision], a], If[Greater[N[Abs[b$95$2], $MachinePrecision], t$95$0], N[(N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[(N[Abs[b$95$2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], Indeterminate], N[Sqrt[b$95$2 ^ 2 + t$95$0 ^ 2], $MachinePrecision]]}, If[Less[b$95$2, 0.0], N[(c / N[(t$95$1 - N[(b$95$2 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b$95$2 / 2.0), $MachinePrecision] + t$95$1), $MachinePrecision] / (-a)), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\left|a\right|} \cdot \sqrt{\left|c\right|}\\
t_1 := \begin{array}{l}
\mathbf{if}\;\mathsf{copysign}\left(a, c\right) = a:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;\left|b_2\right| > t_0:\\
\;\;\;\;\sqrt{\left|b_2\right| - t_0} \cdot \sqrt{\left|b_2\right| + t_0}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{NaN}\\
\end{array}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{hypot}\left(b_2, t_0\right)\\
\end{array}\\
\mathbf{if}\;b_2 < 0:\\
\;\;\;\;\frac{c}{t_1 - \frac{b_2}{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b_2}{2} + t_1}{-a}\\
\end{array}
\end{array}
herbie shell --seed 2023287
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
:herbie-target
(if (< b_2 0.0) (/ c (- (if (== (copysign a c) a) (if (> (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) NAN) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c))))) (/ b_2 2.0))) (/ (+ (/ b_2 2.0) (if (== (copysign a c) a) (if (> (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))) (* (sqrt (- (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c))))) (sqrt (+ (fabs b_2) (* (sqrt (fabs a)) (sqrt (fabs c)))))) NAN) (hypot b_2 (* (sqrt (fabs a)) (sqrt (fabs c)))))) (- a)))
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))