
(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 -6.8e-76)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.05e-17)
(- (/ (- b_2) a) (/ (sqrt (- (* b_2 b_2) (* c a))) a))
(/ (- (- b_2) (+ b_2 (* -0.5 (/ c (/ b_2 a))))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.05e-17) {
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / 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 <= (-6.8d-76)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1.05d-17) then
tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a)
else
tmp = (-b_2 - (b_2 + ((-0.5d0) * (c / (b_2 / a))))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.05e-17) {
tmp = (-b_2 / a) - (Math.sqrt(((b_2 * b_2) - (c * a))) / a);
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.8e-76: tmp = (-0.5 * c) / b_2 elif b_2 <= 1.05e-17: tmp = (-b_2 / a) - (math.sqrt(((b_2 * b_2) - (c * a))) / a) else: tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.8e-76) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.05e-17) tmp = Float64(Float64(Float64(-b_2) / a) - Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a))) / a)); else tmp = Float64(Float64(Float64(-b_2) - Float64(b_2 + Float64(-0.5 * Float64(c / Float64(b_2 / a))))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -6.8e-76) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1.05e-17) tmp = (-b_2 / a) - (sqrt(((b_2 * b_2) - (c * a))) / a); else tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.8e-76], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.05e-17], N[(N[((-b$95$2) / a), $MachinePrecision] - N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[((-b$95$2) - N[(b$95$2 + N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6.8 \cdot 10^{-76}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.05 \cdot 10^{-17}:\\
\;\;\;\;\frac{-b_2}{a} - \frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c}{\frac{b_2}{a}}\right)}{a}\\
\end{array}
\end{array}
if b_2 < -6.7999999999999998e-76Initial program 16.3%
Taylor expanded in b_2 around -inf 87.5%
associate-*r/87.5%
Simplified87.5%
if -6.7999999999999998e-76 < b_2 < 1.04999999999999996e-17Initial program 81.6%
div-sub81.6%
neg-mul-181.6%
*-un-lft-identity81.6%
times-frac81.6%
metadata-eval81.6%
add-sqr-sqrt50.9%
sqrt-prod80.6%
sqr-neg80.6%
sqrt-unprod30.5%
add-sqr-sqrt68.6%
fma-neg68.6%
add-sqr-sqrt30.5%
sqrt-unprod80.6%
sqr-neg80.6%
sqrt-prod50.9%
add-sqr-sqrt81.6%
Applied egg-rr78.6%
fma-neg78.6%
associate-*r/78.6%
mul-1-neg78.6%
Simplified78.6%
hypot-udef75.9%
add-sqr-sqrt75.9%
hypot-udef75.9%
hypot-udef75.9%
pow1/275.9%
hypot-udef75.9%
hypot-udef75.9%
add-sqr-sqrt75.9%
add-sqr-sqrt81.6%
fma-def81.6%
*-commutative81.6%
Applied egg-rr81.6%
unpow1/281.6%
fma-udef81.6%
distribute-lft-neg-out81.6%
unsub-neg81.6%
*-commutative81.6%
Simplified81.6%
if 1.04999999999999996e-17 < b_2 Initial program 67.4%
Taylor expanded in b_2 around inf 84.2%
associate-/l*94.6%
Simplified94.6%
Final simplification87.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -6.8e-76)
(/ (* -0.5 c) b_2)
(if (<= b_2 1.05e-17)
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* c a)))) a)
(/ (- (- b_2) (+ b_2 (* -0.5 (/ c (/ b_2 a))))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.05e-17) {
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / 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 <= (-6.8d-76)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 1.05d-17) then
tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a
else
tmp = (-b_2 - (b_2 + ((-0.5d0) * (c / (b_2 / a))))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 1.05e-17) {
tmp = (-b_2 - Math.sqrt(((b_2 * b_2) - (c * a)))) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.8e-76: tmp = (-0.5 * c) / b_2 elif b_2 <= 1.05e-17: tmp = (-b_2 - math.sqrt(((b_2 * b_2) - (c * a)))) / a else: tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.8e-76) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 1.05e-17) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(b_2 * b_2) - Float64(c * a)))) / a); else tmp = Float64(Float64(Float64(-b_2) - Float64(b_2 + Float64(-0.5 * Float64(c / Float64(b_2 / a))))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -6.8e-76) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 1.05e-17) tmp = (-b_2 - sqrt(((b_2 * b_2) - (c * a)))) / a; else tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.8e-76], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 1.05e-17], 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) - N[(b$95$2 + N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6.8 \cdot 10^{-76}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.05 \cdot 10^{-17}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - c \cdot a}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c}{\frac{b_2}{a}}\right)}{a}\\
\end{array}
\end{array}
if b_2 < -6.7999999999999998e-76Initial program 16.3%
Taylor expanded in b_2 around -inf 87.5%
associate-*r/87.5%
Simplified87.5%
if -6.7999999999999998e-76 < b_2 < 1.04999999999999996e-17Initial program 81.6%
if 1.04999999999999996e-17 < b_2 Initial program 67.4%
Taylor expanded in b_2 around inf 84.2%
associate-/l*94.6%
Simplified94.6%
Final simplification87.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -6.8e-76)
(/ (* -0.5 c) b_2)
(if (<= b_2 2.2e-95)
(/ (- (- b_2) (sqrt (* c (- a)))) a)
(/ (- (- b_2) (+ b_2 (* -0.5 (/ c (/ b_2 a))))) a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.2e-95) {
tmp = (-b_2 - sqrt((c * -a))) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / 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 <= (-6.8d-76)) then
tmp = ((-0.5d0) * c) / b_2
else if (b_2 <= 2.2d-95) then
tmp = (-b_2 - sqrt((c * -a))) / a
else
tmp = (-b_2 - (b_2 + ((-0.5d0) * (c / (b_2 / a))))) / a
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.8e-76) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 2.2e-95) {
tmp = (-b_2 - Math.sqrt((c * -a))) / a;
} else {
tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.8e-76: tmp = (-0.5 * c) / b_2 elif b_2 <= 2.2e-95: tmp = (-b_2 - math.sqrt((c * -a))) / a else: tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.8e-76) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 2.2e-95) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(c * Float64(-a)))) / a); else tmp = Float64(Float64(Float64(-b_2) - Float64(b_2 + Float64(-0.5 * Float64(c / Float64(b_2 / a))))) / a); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -6.8e-76) tmp = (-0.5 * c) / b_2; elseif (b_2 <= 2.2e-95) tmp = (-b_2 - sqrt((c * -a))) / a; else tmp = (-b_2 - (b_2 + (-0.5 * (c / (b_2 / a))))) / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.8e-76], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 2.2e-95], N[(N[((-b$95$2) - N[Sqrt[N[(c * (-a)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[((-b$95$2) - N[(b$95$2 + N[(-0.5 * N[(c / N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6.8 \cdot 10^{-76}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 2.2 \cdot 10^{-95}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{c \cdot \left(-a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-b_2\right) - \left(b_2 + -0.5 \cdot \frac{c}{\frac{b_2}{a}}\right)}{a}\\
\end{array}
\end{array}
if b_2 < -6.7999999999999998e-76Initial program 16.3%
Taylor expanded in b_2 around -inf 87.5%
associate-*r/87.5%
Simplified87.5%
if -6.7999999999999998e-76 < b_2 < 2.1999999999999999e-95Initial program 77.2%
Taylor expanded in b_2 around 0 75.5%
mul-1-neg75.5%
distribute-rgt-neg-out75.5%
Simplified75.5%
if 2.1999999999999999e-95 < b_2 Initial program 73.8%
Taylor expanded in b_2 around inf 79.1%
associate-/l*87.5%
Simplified87.5%
Final simplification84.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2e-310) (/ (* -0.5 c) b_2) (+ (* (/ b_2 a) -2.0) (* 0.5 (/ c b_2)))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2e-310) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = ((b_2 / a) * -2.0) + (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 = ((-0.5d0) * c) / b_2
else
tmp = ((b_2 / a) * (-2.0d0)) + (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 = (-0.5 * c) / b_2;
} else {
tmp = ((b_2 / a) * -2.0) + (0.5 * (c / b_2));
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2e-310: tmp = (-0.5 * c) / b_2 else: tmp = ((b_2 / a) * -2.0) + (0.5 * (c / b_2)) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2e-310) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(Float64(Float64(b_2 / a) * -2.0) + 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 = (-0.5 * c) / b_2; else tmp = ((b_2 / a) * -2.0) + (0.5 * (c / b_2)); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2e-310], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(N[(N[(b$95$2 / a), $MachinePrecision] * -2.0), $MachinePrecision] + N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2 \cdot 10^{-310}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2}{a} \cdot -2 + 0.5 \cdot \frac{c}{b_2}\\
\end{array}
\end{array}
if b_2 < -1.999999999999994e-310Initial program 33.8%
Taylor expanded in b_2 around -inf 67.2%
associate-*r/67.2%
Simplified67.2%
if -1.999999999999994e-310 < b_2 Initial program 75.4%
Taylor expanded in b_2 around inf 66.9%
Final simplification67.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -10500000000000.0) (* 0.5 (/ c b_2)) (* b_2 (/ -2.0 a))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -10500000000000.0) {
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 <= (-10500000000000.0d0)) 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 <= -10500000000000.0) {
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 <= -10500000000000.0: 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 <= -10500000000000.0) tmp = Float64(0.5 * Float64(c / b_2)); else tmp = Float64(b_2 * Float64(-2.0 / a)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -10500000000000.0) 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, -10500000000000.0], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(b$95$2 * N[(-2.0 / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -10500000000000:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;b_2 \cdot \frac{-2}{a}\\
\end{array}
\end{array}
if b_2 < -1.05e13Initial program 14.3%
Taylor expanded in b_2 around inf 2.4%
Taylor expanded in b_2 around 0 36.3%
if -1.05e13 < b_2 Initial program 72.5%
Taylor expanded in b_2 around inf 49.0%
Taylor expanded in b_2 around inf 49.3%
associate-*r/49.3%
associate-*l/49.2%
*-commutative49.2%
Simplified49.2%
Final simplification45.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -72000000.0) (* 0.5 (/ c b_2)) (/ -2.0 (/ a b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -72000000.0) {
tmp = 0.5 * (c / b_2);
} else {
tmp = -2.0 / (a / 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 <= (-72000000.0d0)) then
tmp = 0.5d0 * (c / b_2)
else
tmp = (-2.0d0) / (a / b_2)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -72000000.0) {
tmp = 0.5 * (c / b_2);
} else {
tmp = -2.0 / (a / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -72000000.0: tmp = 0.5 * (c / b_2) else: tmp = -2.0 / (a / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -72000000.0) tmp = Float64(0.5 * Float64(c / b_2)); else tmp = Float64(-2.0 / Float64(a / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -72000000.0) tmp = 0.5 * (c / b_2); else tmp = -2.0 / (a / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -72000000.0], N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision], N[(-2.0 / N[(a / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -72000000:\\
\;\;\;\;0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{\frac{a}{b_2}}\\
\end{array}
\end{array}
if b_2 < -7.2e7Initial program 14.3%
Taylor expanded in b_2 around inf 2.4%
Taylor expanded in b_2 around 0 36.3%
if -7.2e7 < b_2 Initial program 72.5%
add-exp-log40.9%
add-sqr-sqrt9.5%
sqrt-unprod21.9%
sqr-neg21.9%
sqrt-prod17.0%
add-sqr-sqrt25.9%
sub-neg25.9%
add-sqr-sqrt23.8%
hypot-def21.7%
*-commutative21.7%
distribute-rgt-neg-in21.7%
Applied egg-rr21.7%
Taylor expanded in b_2 around -inf 2.5%
add-sqr-sqrt1.6%
sqrt-unprod21.5%
swap-sqr21.5%
metadata-eval21.5%
metadata-eval21.5%
swap-sqr21.5%
sqrt-unprod27.4%
add-sqr-sqrt49.3%
clear-num49.2%
un-div-inv49.2%
Applied egg-rr49.2%
Final simplification45.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.8e-275) (/ (* -0.5 c) b_2) (/ -2.0 (/ a b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.8e-275) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 / (a / 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-275)) then
tmp = ((-0.5d0) * c) / b_2
else
tmp = (-2.0d0) / (a / 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-275) {
tmp = (-0.5 * c) / b_2;
} else {
tmp = -2.0 / (a / b_2);
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -2.8e-275: tmp = (-0.5 * c) / b_2 else: tmp = -2.0 / (a / b_2) return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -2.8e-275) tmp = Float64(Float64(-0.5 * c) / b_2); else tmp = Float64(-2.0 / Float64(a / b_2)); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -2.8e-275) tmp = (-0.5 * c) / b_2; else tmp = -2.0 / (a / b_2); end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.8e-275], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], N[(-2.0 / N[(a / b$95$2), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -2.8 \cdot 10^{-275}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{-2}{\frac{a}{b_2}}\\
\end{array}
\end{array}
if b_2 < -2.79999999999999994e-275Initial program 31.7%
Taylor expanded in b_2 around -inf 69.2%
associate-*r/69.3%
Simplified69.3%
if -2.79999999999999994e-275 < b_2 Initial program 76.1%
add-exp-log44.1%
add-sqr-sqrt2.1%
sqrt-unprod18.6%
sqr-neg18.6%
sqrt-prod22.7%
add-sqr-sqrt24.0%
sub-neg24.0%
add-sqr-sqrt21.2%
hypot-def18.5%
*-commutative18.5%
distribute-rgt-neg-in18.5%
Applied egg-rr18.5%
Taylor expanded in b_2 around -inf 1.8%
add-sqr-sqrt1.0%
sqrt-unprod27.4%
swap-sqr27.4%
metadata-eval27.4%
metadata-eval27.4%
swap-sqr27.4%
sqrt-unprod35.9%
add-sqr-sqrt64.8%
clear-num64.6%
un-div-inv64.6%
Applied egg-rr64.6%
Final simplification66.9%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -2.9e-275) (/ (* -0.5 c) b_2) (/ (* b_2 -2.0) a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.9e-275) {
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 <= (-2.9d-275)) 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 <= -2.9e-275) {
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 <= -2.9e-275: 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 <= -2.9e-275) 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 <= -2.9e-275) 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, -2.9e-275], 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 -2.9 \cdot 10^{-275}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
\end{array}
if b_2 < -2.9e-275Initial program 31.7%
Taylor expanded in b_2 around -inf 69.2%
associate-*r/69.3%
Simplified69.3%
if -2.9e-275 < b_2 Initial program 76.1%
Taylor expanded in b_2 around inf 64.8%
*-commutative64.8%
Simplified64.8%
Final simplification66.9%
(FPCore (a b_2 c) :precision binary64 (* 0.5 (/ c b_2)))
double code(double a, double b_2, double c) {
return 0.5 * (c / b_2);
}
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.5d0 * (c / b_2)
end function
public static double code(double a, double b_2, double c) {
return 0.5 * (c / b_2);
}
def code(a, b_2, c): return 0.5 * (c / b_2)
function code(a, b_2, c) return Float64(0.5 * Float64(c / b_2)) end
function tmp = code(a, b_2, c) tmp = 0.5 * (c / b_2); end
code[a_, b$95$2_, c_] := N[(0.5 * N[(c / b$95$2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \frac{c}{b_2}
\end{array}
Initial program 54.8%
Taylor expanded in b_2 around inf 31.8%
Taylor expanded in b_2 around 0 13.4%
Final simplification13.4%
herbie shell --seed 2023257
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))