
(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+153)
(/ (* b_2 -2.0) a)
(if (<= b_2 7.7e-53)
(/ (- (sqrt (- (* b_2 b_2) (* a c))) b_2) a)
(/ 1.0 (fma 0.5 (/ a b_2) (* -2.0 (/ b_2 c)))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6e+153) {
tmp = (b_2 * -2.0) / a;
} else if (b_2 <= 7.7e-53) {
tmp = (sqrt(((b_2 * b_2) - (a * c))) - b_2) / a;
} else {
tmp = 1.0 / fma(0.5, (a / b_2), (-2.0 * (b_2 / c)));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6e+153) tmp = Float64(Float64(b_2 * -2.0) / a); elseif (b_2 <= 7.7e-53) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c))) - b_2) / a); else tmp = Float64(1.0 / fma(0.5, Float64(a / b_2), Float64(-2.0 * Float64(b_2 / c)))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6e+153], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 7.7e-53], 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[(1.0 / N[(0.5 * N[(a / b$95$2), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6 \cdot 10^{+153}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{elif}\;b_2 \leq 7.7 \cdot 10^{-53}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, -2 \cdot \frac{b_2}{c}\right)}\\
\end{array}
\end{array}
if b_2 < -6.00000000000000037e153Initial program 37.7%
+-commutative37.7%
unsub-neg37.7%
Simplified37.7%
Taylor expanded in b_2 around -inf 100.0%
*-commutative100.0%
Simplified100.0%
if -6.00000000000000037e153 < b_2 < 7.69999999999999995e-53Initial program 80.6%
+-commutative80.6%
unsub-neg80.6%
Simplified80.6%
if 7.69999999999999995e-53 < b_2 Initial program 15.4%
+-commutative15.4%
unsub-neg15.4%
Simplified15.4%
add-cbrt-cube9.1%
pow39.1%
pow1/37.1%
sqrt-pow27.1%
fma-neg7.1%
*-commutative7.1%
distribute-rgt-neg-in7.1%
metadata-eval7.1%
Applied egg-rr7.1%
unpow1/39.2%
distribute-rgt-neg-out9.2%
*-commutative9.2%
fma-neg9.2%
*-commutative9.2%
Simplified9.2%
clear-num9.2%
inv-pow9.2%
pow1/37.1%
pow-pow15.4%
metadata-eval15.4%
pow1/215.4%
sub-neg15.4%
distribute-rgt-neg-out15.4%
add-sqr-sqrt13.3%
hypot-udef22.4%
Applied egg-rr22.4%
unpow-122.4%
Simplified22.4%
Taylor expanded in b_2 around inf 0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt90.3%
times-frac90.3%
metadata-eval90.3%
Simplified90.3%
Final simplification86.6%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8.2e-28)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 3.4e-56)
(/ (- (sqrt (* a (- c))) b_2) a)
(/ 1.0 (fma 0.5 (/ a b_2) (* -2.0 (/ b_2 c)))))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -8.2e-28) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 3.4e-56) {
tmp = (sqrt((a * -c)) - b_2) / a;
} else {
tmp = 1.0 / fma(0.5, (a / b_2), (-2.0 * (b_2 / c)));
}
return tmp;
}
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -8.2e-28) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 3.4e-56) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a); else tmp = Float64(1.0 / fma(0.5, Float64(a / b_2), Float64(-2.0 * Float64(b_2 / c)))); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8.2e-28], 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, 3.4e-56], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(1.0 / N[(0.5 * N[(a / b$95$2), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -8.2 \cdot 10^{-28}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3.4 \cdot 10^{-56}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(0.5, \frac{a}{b_2}, -2 \cdot \frac{b_2}{c}\right)}\\
\end{array}
\end{array}
if b_2 < -8.2000000000000005e-28Initial program 64.4%
+-commutative64.4%
unsub-neg64.4%
Simplified64.4%
Taylor expanded in b_2 around -inf 92.6%
if -8.2000000000000005e-28 < b_2 < 3.39999999999999982e-56Initial program 76.0%
+-commutative76.0%
unsub-neg76.0%
Simplified76.0%
Taylor expanded in b_2 around 0 67.8%
mul-1-neg67.8%
distribute-rgt-neg-out67.8%
Simplified67.8%
if 3.39999999999999982e-56 < b_2 Initial program 15.4%
+-commutative15.4%
unsub-neg15.4%
Simplified15.4%
add-cbrt-cube9.1%
pow39.1%
pow1/37.1%
sqrt-pow27.1%
fma-neg7.1%
*-commutative7.1%
distribute-rgt-neg-in7.1%
metadata-eval7.1%
Applied egg-rr7.1%
unpow1/39.2%
distribute-rgt-neg-out9.2%
*-commutative9.2%
fma-neg9.2%
*-commutative9.2%
Simplified9.2%
clear-num9.2%
inv-pow9.2%
pow1/37.1%
pow-pow15.4%
metadata-eval15.4%
pow1/215.4%
sub-neg15.4%
distribute-rgt-neg-out15.4%
add-sqr-sqrt13.3%
hypot-udef22.4%
Applied egg-rr22.4%
unpow-122.4%
Simplified22.4%
Taylor expanded in b_2 around inf 0.0%
fma-def0.0%
associate-*r/0.0%
*-commutative0.0%
unpow20.0%
rem-square-sqrt90.3%
times-frac90.3%
metadata-eval90.3%
Simplified90.3%
Final simplification82.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -6.2e-28) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 4.6e-55) (/ (- (sqrt (* a (- c))) b_2) a) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.2e-28) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 4.6e-55) {
tmp = (sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c / b_2) * -0.5;
}
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.2d-28)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 4.6d-55) then
tmp = (sqrt((a * -c)) - b_2) / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -6.2e-28) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 4.6e-55) {
tmp = (Math.sqrt((a * -c)) - b_2) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -6.2e-28: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 4.6e-55: tmp = (math.sqrt((a * -c)) - b_2) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -6.2e-28) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 4.6e-55) tmp = Float64(Float64(sqrt(Float64(a * Float64(-c))) - b_2) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -6.2e-28) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 4.6e-55) tmp = (sqrt((a * -c)) - b_2) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -6.2e-28], 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, 4.6e-55], N[(N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -6.2 \cdot 10^{-28}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 4.6 \cdot 10^{-55}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -6.19999999999999984e-28Initial program 64.4%
+-commutative64.4%
unsub-neg64.4%
Simplified64.4%
Taylor expanded in b_2 around -inf 92.6%
if -6.19999999999999984e-28 < b_2 < 4.60000000000000023e-55Initial program 76.0%
+-commutative76.0%
unsub-neg76.0%
Simplified76.0%
Taylor expanded in b_2 around 0 67.8%
mul-1-neg67.8%
distribute-rgt-neg-out67.8%
Simplified67.8%
if 4.60000000000000023e-55 < b_2 Initial program 15.4%
+-commutative15.4%
unsub-neg15.4%
Simplified15.4%
Taylor expanded in b_2 around inf 89.9%
Final simplification82.7%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -7.2e-75) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 3.25e-57) (/ (sqrt (* a (- c))) a) (* (/ c b_2) -0.5))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.2e-75) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 3.25e-57) {
tmp = sqrt((a * -c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
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.2d-75)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 3.25d-57) then
tmp = sqrt((a * -c)) / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -7.2e-75) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 3.25e-57) {
tmp = Math.sqrt((a * -c)) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -7.2e-75: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 3.25e-57: tmp = math.sqrt((a * -c)) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -7.2e-75) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 3.25e-57) tmp = Float64(sqrt(Float64(a * Float64(-c))) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -7.2e-75) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 3.25e-57) tmp = sqrt((a * -c)) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -7.2e-75], 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, 3.25e-57], N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -7.2 \cdot 10^{-75}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 3.25 \cdot 10^{-57}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -7.2000000000000001e-75Initial program 67.1%
+-commutative67.1%
unsub-neg67.1%
Simplified67.1%
Taylor expanded in b_2 around -inf 89.5%
if -7.2000000000000001e-75 < b_2 < 3.24999999999999996e-57Initial program 73.8%
+-commutative73.8%
unsub-neg73.8%
Simplified73.8%
prod-diff73.4%
*-commutative73.4%
fma-def73.4%
associate-+l+73.4%
distribute-rgt-neg-in73.4%
fma-def73.4%
*-commutative73.4%
fma-udef73.4%
distribute-lft-neg-in73.4%
*-commutative73.4%
distribute-rgt-neg-in73.4%
fma-def73.4%
Applied egg-rr73.4%
Taylor expanded in b_2 around 0 67.0%
associate-*l/67.1%
*-lft-identity67.1%
distribute-rgt1-in67.5%
metadata-eval67.5%
neg-mul-167.5%
*-commutative67.5%
Simplified67.5%
if 3.24999999999999996e-57 < b_2 Initial program 15.4%
+-commutative15.4%
unsub-neg15.4%
Simplified15.4%
Taylor expanded in b_2 around inf 89.9%
Final simplification82.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-310) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c / b_2) * -0.5;
}
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 <= (-5d-310)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-310) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-310: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-310) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= -5e-310) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -5e-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 / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -4.999999999999985e-310Initial program 70.7%
+-commutative70.7%
unsub-neg70.7%
Simplified70.7%
Taylor expanded in b_2 around -inf 69.2%
if -4.999999999999985e-310 < b_2 Initial program 37.1%
+-commutative37.1%
unsub-neg37.1%
Simplified37.1%
Taylor expanded in b_2 around inf 64.3%
Final simplification67.0%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.4e-235) (/ (- b_2) a) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.4e-235) {
tmp = -b_2 / a;
} else {
tmp = (c / b_2) * -0.5;
}
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.4d-235) then
tmp = -b_2 / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.4e-235) {
tmp = -b_2 / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 1.4e-235: tmp = -b_2 / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 1.4e-235) tmp = Float64(Float64(-b_2) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 1.4e-235) tmp = -b_2 / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.4e-235], N[((-b$95$2) / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.4 \cdot 10^{-235}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < 1.39999999999999998e-235Initial program 71.3%
+-commutative71.3%
unsub-neg71.3%
Simplified71.3%
add-cbrt-cube58.6%
pow358.6%
pow1/355.8%
sqrt-pow255.8%
fma-neg56.0%
*-commutative56.0%
distribute-rgt-neg-in56.0%
metadata-eval56.0%
Applied egg-rr56.0%
unpow1/358.7%
distribute-rgt-neg-out58.7%
*-commutative58.7%
fma-neg58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in c around inf 14.3%
*-commutative14.3%
exp-prod14.3%
+-commutative14.3%
mul-1-neg14.3%
log-rec14.3%
remove-double-neg14.3%
log-prod34.9%
rem-exp-log36.3%
distribute-rgt-neg-out36.3%
*-commutative36.3%
Simplified36.3%
Taylor expanded in a around 0 24.7%
associate-*r/24.7%
neg-mul-124.7%
Simplified24.7%
if 1.39999999999999998e-235 < b_2 Initial program 32.6%
+-commutative32.6%
unsub-neg32.6%
Simplified32.6%
Taylor expanded in b_2 around inf 70.9%
Final simplification43.1%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 1.4e-235) (/ (* b_2 -2.0) a) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.4e-235) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c / b_2) * -0.5;
}
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.4d-235) then
tmp = (b_2 * (-2.0d0)) / a
else
tmp = (c / b_2) * (-0.5d0)
end if
code = tmp
end function
public static double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= 1.4e-235) {
tmp = (b_2 * -2.0) / a;
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= 1.4e-235: tmp = (b_2 * -2.0) / a else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= 1.4e-235) tmp = Float64(Float64(b_2 * -2.0) / a); else tmp = Float64(Float64(c / b_2) * -0.5); end return tmp end
function tmp_2 = code(a, b_2, c) tmp = 0.0; if (b_2 <= 1.4e-235) tmp = (b_2 * -2.0) / a; else tmp = (c / b_2) * -0.5; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, 1.4e-235], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision], N[(N[(c / b$95$2), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq 1.4 \cdot 10^{-235}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < 1.39999999999999998e-235Initial program 71.3%
+-commutative71.3%
unsub-neg71.3%
Simplified71.3%
Taylor expanded in b_2 around -inf 64.2%
*-commutative64.2%
Simplified64.2%
if 1.39999999999999998e-235 < b_2 Initial program 32.6%
+-commutative32.6%
unsub-neg32.6%
Simplified32.6%
Taylor expanded in b_2 around inf 70.9%
Final simplification66.9%
(FPCore (a b_2 c) :precision binary64 (/ (- b_2) a))
double code(double a, double b_2, double c) {
return -b_2 / 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 / a
end function
public static double code(double a, double b_2, double c) {
return -b_2 / a;
}
def code(a, b_2, c): return -b_2 / a
function code(a, b_2, c) return Float64(Float64(-b_2) / a) end
function tmp = code(a, b_2, c) tmp = -b_2 / a; end
code[a_, b$95$2_, c_] := N[((-b$95$2) / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{-b_2}{a}
\end{array}
Initial program 55.9%
+-commutative55.9%
unsub-neg55.9%
Simplified55.9%
add-cbrt-cube45.1%
pow345.1%
pow1/342.5%
sqrt-pow242.5%
fma-neg42.5%
*-commutative42.5%
distribute-rgt-neg-in42.5%
metadata-eval42.5%
Applied egg-rr42.5%
unpow1/345.2%
distribute-rgt-neg-out45.2%
*-commutative45.2%
fma-neg45.1%
*-commutative45.1%
Simplified45.1%
Taylor expanded in c around inf 12.5%
*-commutative12.5%
exp-prod12.5%
+-commutative12.5%
mul-1-neg12.5%
log-rec12.5%
remove-double-neg12.5%
log-prod29.0%
rem-exp-log30.2%
distribute-rgt-neg-out30.2%
*-commutative30.2%
Simplified30.2%
Taylor expanded in a around 0 15.9%
associate-*r/15.9%
neg-mul-115.9%
Simplified15.9%
Final simplification15.9%
herbie shell --seed 2023213
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))