
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b_2 c) :precision binary64 (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
double code(double a, double b_2, double c) {
return (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a;
}
real(8) function code(a, b_2, c)
real(8), intent (in) :: a
real(8), intent (in) :: b_2
real(8), intent (in) :: c
code = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a
end function
public static double code(double a, double b_2, double c) {
return (-b_2 + Math.sqrt(((b_2 * b_2) - (a * c)))) / a;
}
def code(a, b_2, c): return (-b_2 + math.sqrt(((b_2 * b_2) - (a * c)))) / a
function code(a, b_2, c) return Float64(Float64(Float64(-b_2) + sqrt(Float64(Float64(b_2 * b_2) - Float64(a * c)))) / a) end
function tmp = code(a, b_2, c) tmp = (-b_2 + sqrt(((b_2 * b_2) - (a * c)))) / a; end
code[a_, b$95$2_, c_] := N[(N[((-b$95$2) + N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(a * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\end{array}
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -8e+114)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 -2.25e-255)
(/ (- (pow (fma b_2 b_2 (* a (- c))) 0.5) b_2) a)
(if (<= b_2 3.5e-292)
(/ (- (pow (exp (* 0.25 (- (log a) (log (/ -1.0 c))))) 2.0) b_2) a)
(if (<= b_2 2.2e-25)
(/ (- (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 <= -8e+114) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= -2.25e-255) {
tmp = (pow(fma(b_2, b_2, (a * -c)), 0.5) - b_2) / a;
} else if (b_2 <= 3.5e-292) {
tmp = (pow(exp((0.25 * (log(a) - log((-1.0 / c))))), 2.0) - b_2) / a;
} else if (b_2 <= 2.2e-25) {
tmp = (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 <= -8e+114) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= -2.25e-255) tmp = Float64(Float64((fma(b_2, b_2, Float64(a * Float64(-c))) ^ 0.5) - b_2) / a); elseif (b_2 <= 3.5e-292) tmp = Float64(Float64((exp(Float64(0.25 * Float64(log(a) - log(Float64(-1.0 / c))))) ^ 2.0) - b_2) / a); elseif (b_2 <= 2.2e-25) 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
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -8e+114], 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.25e-255], N[(N[(N[Power[N[(b$95$2 * b$95$2 + N[(a * (-c)), $MachinePrecision]), $MachinePrecision], 0.5], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 3.5e-292], N[(N[(N[Power[N[Exp[N[(0.25 * N[(N[Log[a], $MachinePrecision] - N[Log[N[(-1.0 / c), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b$95$2, 2.2e-25], 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 -8 \cdot 10^{+114}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq -2.25 \cdot 10^{-255}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)\right)}^{0.5} - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 3.5 \cdot 10^{-292}:\\
\;\;\;\;\frac{{\left(e^{0.25 \cdot \left(\log a - \log \left(\frac{-1}{c}\right)\right)}\right)}^{2} - b_2}{a}\\
\mathbf{elif}\;b_2 \leq 2.2 \cdot 10^{-25}:\\
\;\;\;\;\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 < -8e114Initial program 35.5%
+-commutative35.5%
unsub-neg35.5%
Simplified35.5%
Taylor expanded in b_2 around -inf 93.8%
if -8e114 < b_2 < -2.2499999999999999e-255Initial program 86.6%
+-commutative86.6%
unsub-neg86.6%
Simplified86.6%
pow1/286.6%
fma-neg86.6%
*-commutative86.6%
distribute-rgt-neg-in86.6%
Applied egg-rr86.6%
if -2.2499999999999999e-255 < b_2 < 3.5e-292Initial program 39.3%
+-commutative39.3%
unsub-neg39.3%
Simplified39.3%
add-sqr-sqrt39.1%
pow239.1%
pow1/239.1%
sqrt-pow139.1%
fma-neg39.1%
*-commutative39.1%
distribute-rgt-neg-in39.1%
metadata-eval39.1%
Applied egg-rr39.1%
Taylor expanded in c around -inf 89.7%
if 3.5e-292 < b_2 < 2.2000000000000002e-25Initial program 73.8%
+-commutative73.8%
unsub-neg73.8%
Simplified73.8%
if 2.2000000000000002e-25 < b_2 Initial program 8.6%
+-commutative8.6%
unsub-neg8.6%
Simplified8.6%
Taylor expanded in b_2 around inf 73.2%
associate-*r/73.2%
associate-/l*73.1%
Simplified73.1%
*-un-lft-identity73.1%
times-frac75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in b_2 around 0 95.2%
associate-*r/95.3%
Simplified95.3%
Final simplification87.9%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.55e+116)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 1.55e-24)
(/ (- (pow (fma b_2 b_2 (* a (- c))) 0.5) b_2) a)
(/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -2.55e+116) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 1.55e-24) {
tmp = (pow(fma(b_2, b_2, (a * -c)), 0.5) - 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.55e+116) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 1.55e-24) tmp = Float64(Float64((fma(b_2, b_2, Float64(a * Float64(-c))) ^ 0.5) - b_2) / a); else tmp = Float64(Float64(c * -0.5) / b_2); end return tmp end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -2.55e+116], 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, 1.55e-24], N[(N[(N[Power[N[(b$95$2 * b$95$2 + N[(a * (-c)), $MachinePrecision]), $MachinePrecision], 0.5], $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.55 \cdot 10^{+116}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 1.55 \cdot 10^{-24}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(b_2, b_2, a \cdot \left(-c\right)\right)\right)}^{0.5} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -2.55e116Initial program 35.5%
+-commutative35.5%
unsub-neg35.5%
Simplified35.5%
Taylor expanded in b_2 around -inf 93.8%
if -2.55e116 < b_2 < 1.55e-24Initial program 78.8%
+-commutative78.8%
unsub-neg78.8%
Simplified78.8%
pow1/278.8%
fma-neg78.8%
*-commutative78.8%
distribute-rgt-neg-in78.8%
Applied egg-rr78.8%
if 1.55e-24 < b_2 Initial program 8.6%
+-commutative8.6%
unsub-neg8.6%
Simplified8.6%
Taylor expanded in b_2 around inf 73.2%
associate-*r/73.2%
associate-/l*73.1%
Simplified73.1%
*-un-lft-identity73.1%
times-frac75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in b_2 around 0 95.2%
associate-*r/95.3%
Simplified95.3%
Final simplification86.4%
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -2.4e+116)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 9.5e-26)
(/ (- (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.4e+116) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 9.5e-26) {
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.4d+116)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 9.5d-26) 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.4e+116) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 9.5e-26) {
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.4e+116: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 9.5e-26: 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.4e+116) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 9.5e-26) 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.4e+116) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 9.5e-26) 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.4e+116], 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, 9.5e-26], 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.4 \cdot 10^{+116}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 9.5 \cdot 10^{-26}:\\
\;\;\;\;\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.4e116Initial program 35.5%
+-commutative35.5%
unsub-neg35.5%
Simplified35.5%
Taylor expanded in b_2 around -inf 93.8%
if -2.4e116 < b_2 < 9.4999999999999995e-26Initial program 78.8%
+-commutative78.8%
unsub-neg78.8%
Simplified78.8%
if 9.4999999999999995e-26 < b_2 Initial program 8.6%
+-commutative8.6%
unsub-neg8.6%
Simplified8.6%
Taylor expanded in b_2 around inf 73.2%
associate-*r/73.2%
associate-/l*73.1%
Simplified73.1%
*-un-lft-identity73.1%
times-frac75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in b_2 around 0 95.2%
associate-*r/95.3%
Simplified95.3%
Final simplification86.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -1.8e-11) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 9.5e-26) (/ (- (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 <= -1.8e-11) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 9.5e-26) {
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 <= (-1.8d-11)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 9.5d-26) 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 <= -1.8e-11) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 9.5e-26) {
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 <= -1.8e-11: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 9.5e-26: 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 <= -1.8e-11) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 9.5e-26) 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 <= -1.8e-11) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 9.5e-26) 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, -1.8e-11], 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, 9.5e-26], 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 -1.8 \cdot 10^{-11}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 9.5 \cdot 10^{-26}:\\
\;\;\;\;\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 < -1.79999999999999992e-11Initial program 56.5%
+-commutative56.5%
unsub-neg56.5%
Simplified56.5%
Taylor expanded in b_2 around -inf 87.9%
if -1.79999999999999992e-11 < b_2 < 9.4999999999999995e-26Initial program 74.2%
+-commutative74.2%
unsub-neg74.2%
Simplified74.2%
Taylor expanded in b_2 around 0 68.4%
associate-*r*68.4%
neg-mul-168.4%
*-commutative68.4%
Simplified68.4%
if 9.4999999999999995e-26 < b_2 Initial program 8.6%
+-commutative8.6%
unsub-neg8.6%
Simplified8.6%
Taylor expanded in b_2 around inf 73.2%
associate-*r/73.2%
associate-/l*73.1%
Simplified73.1%
*-un-lft-identity73.1%
times-frac75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in b_2 around 0 95.2%
associate-*r/95.3%
Simplified95.3%
Final simplification81.8%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -4.3e-51) (+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2))) (if (<= b_2 4.7e-26) (/ (sqrt (* a (- c))) a) (/ (* c -0.5) b_2))))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -4.3e-51) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 4.7e-26) {
tmp = sqrt((a * -c)) / 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 <= (-4.3d-51)) then
tmp = ((-2.0d0) * (b_2 / a)) + (0.5d0 * (c / b_2))
else if (b_2 <= 4.7d-26) then
tmp = sqrt((a * -c)) / 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 <= -4.3e-51) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 4.7e-26) {
tmp = Math.sqrt((a * -c)) / a;
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -4.3e-51: tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)) elif b_2 <= 4.7e-26: tmp = math.sqrt((a * -c)) / a else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -4.3e-51) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 4.7e-26) tmp = Float64(sqrt(Float64(a * Float64(-c))) / 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 <= -4.3e-51) tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2)); elseif (b_2 <= 4.7e-26) tmp = sqrt((a * -c)) / a; else tmp = (c * -0.5) / b_2; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -4.3e-51], 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.7e-26], N[(N[Sqrt[N[(a * (-c)), $MachinePrecision]], $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -4.3 \cdot 10^{-51}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 4.7 \cdot 10^{-26}:\\
\;\;\;\;\frac{\sqrt{a \cdot \left(-c\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -4.2999999999999997e-51Initial program 61.3%
+-commutative61.3%
unsub-neg61.3%
Simplified61.3%
Taylor expanded in b_2 around -inf 84.2%
if -4.2999999999999997e-51 < b_2 < 4.69999999999999989e-26Initial program 71.5%
+-commutative71.5%
unsub-neg71.5%
Simplified71.5%
prod-diff71.1%
*-commutative71.1%
fma-def71.1%
associate-+l+71.1%
distribute-rgt-neg-in71.1%
fma-def71.1%
*-commutative71.1%
fma-udef71.1%
distribute-lft-neg-in71.1%
*-commutative71.1%
distribute-rgt-neg-in71.1%
fma-def71.1%
Applied egg-rr71.1%
Taylor expanded in b_2 around 0 68.4%
associate-*l/68.5%
*-lft-identity68.5%
distribute-lft1-in68.8%
metadata-eval68.8%
neg-mul-168.8%
*-commutative68.8%
distribute-rgt-neg-out68.8%
distribute-rgt-neg-out68.8%
*-commutative68.8%
Simplified68.8%
if 4.69999999999999989e-26 < b_2 Initial program 8.6%
+-commutative8.6%
unsub-neg8.6%
Simplified8.6%
Taylor expanded in b_2 around inf 73.2%
associate-*r/73.2%
associate-/l*73.1%
Simplified73.1%
*-un-lft-identity73.1%
times-frac75.0%
Applied egg-rr75.0%
associate-*l/75.0%
*-lft-identity75.0%
Simplified75.0%
Taylor expanded in b_2 around 0 95.2%
associate-*r/95.3%
Simplified95.3%
Final simplification81.4%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-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 <= -5e-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 <= (-5d-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 <= -5e-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 <= -5e-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 <= -5e-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 <= -5e-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, -5e-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 -5 \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 < -5.00000000000023e-311Initial program 64.6%
+-commutative64.6%
unsub-neg64.6%
Simplified64.6%
Taylor expanded in b_2 around -inf 62.3%
if -5.00000000000023e-311 < b_2 Initial program 36.0%
+-commutative36.0%
unsub-neg36.0%
Simplified36.0%
Taylor expanded in b_2 around inf 46.9%
associate-*r/46.9%
associate-/l*46.9%
Simplified46.9%
*-un-lft-identity46.9%
times-frac52.5%
Applied egg-rr52.5%
associate-*l/52.5%
*-lft-identity52.5%
Simplified52.5%
Taylor expanded in b_2 around 0 64.7%
associate-*r/64.8%
Simplified64.8%
Final simplification63.5%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -9e-308) (* -2.0 (/ b_2 a)) (/ 0.0 a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e-308) {
tmp = -2.0 * (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 <= (-9d-308)) then
tmp = (-2.0d0) * (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 <= -9e-308) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9e-308: tmp = -2.0 * (b_2 / a) else: tmp = 0.0 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9e-308) tmp = Float64(-2.0 * 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 <= -9e-308) tmp = -2.0 * (b_2 / a); else tmp = 0.0 / a; end tmp_2 = tmp; end
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -9e-308], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -9 \cdot 10^{-308}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b_2 < -9.00000000000000017e-308Initial program 65.1%
+-commutative65.1%
unsub-neg65.1%
Simplified65.1%
Taylor expanded in b_2 around -inf 62.5%
if -9.00000000000000017e-308 < b_2 Initial program 35.8%
+-commutative35.8%
unsub-neg35.8%
Simplified35.8%
add-sqr-sqrt35.5%
pow235.5%
pow1/235.5%
sqrt-pow135.4%
fma-neg35.4%
*-commutative35.4%
distribute-rgt-neg-in35.4%
metadata-eval35.4%
Applied egg-rr35.4%
Taylor expanded in b_2 around inf 20.6%
distribute-rgt1-in20.6%
metadata-eval20.6%
mul0-lft20.6%
Simplified20.6%
Final simplification42.2%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-311) (* -2.0 (/ b_2 a)) (* (/ c b_2) -0.5)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-311) {
tmp = -2.0 * (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 <= (-5d-311)) then
tmp = (-2.0d0) * (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 <= -5e-311) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (c / b_2) * -0.5;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-311: tmp = -2.0 * (b_2 / a) else: tmp = (c / b_2) * -0.5 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-311) tmp = Float64(-2.0 * 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 <= -5e-311) tmp = -2.0 * (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, -5e-311], N[(-2.0 * N[(b$95$2 / a), $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^{-311}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{b_2} \cdot -0.5\\
\end{array}
\end{array}
if b_2 < -5.00000000000023e-311Initial program 64.6%
+-commutative64.6%
unsub-neg64.6%
Simplified64.6%
Taylor expanded in b_2 around -inf 62.0%
if -5.00000000000023e-311 < b_2 Initial program 36.0%
+-commutative36.0%
unsub-neg36.0%
Simplified36.0%
Taylor expanded in b_2 around inf 64.7%
Final simplification63.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -5e-311) (* -2.0 (/ b_2 a)) (/ (* c -0.5) b_2)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -5e-311) {
tmp = -2.0 * (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 <= (-5d-311)) then
tmp = (-2.0d0) * (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 <= -5e-311) {
tmp = -2.0 * (b_2 / a);
} else {
tmp = (c * -0.5) / b_2;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -5e-311: tmp = -2.0 * (b_2 / a) else: tmp = (c * -0.5) / b_2 return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -5e-311) tmp = Float64(-2.0 * 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 <= -5e-311) tmp = -2.0 * (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, -5e-311], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -5 \cdot 10^{-311}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
\end{array}
if b_2 < -5.00000000000023e-311Initial program 64.6%
+-commutative64.6%
unsub-neg64.6%
Simplified64.6%
Taylor expanded in b_2 around -inf 62.0%
if -5.00000000000023e-311 < b_2 Initial program 36.0%
+-commutative36.0%
unsub-neg36.0%
Simplified36.0%
Taylor expanded in b_2 around inf 46.9%
associate-*r/46.9%
associate-/l*46.9%
Simplified46.9%
*-un-lft-identity46.9%
times-frac52.5%
Applied egg-rr52.5%
associate-*l/52.5%
*-lft-identity52.5%
Simplified52.5%
Taylor expanded in b_2 around 0 64.7%
associate-*r/64.8%
Simplified64.8%
Final simplification63.3%
(FPCore (a b_2 c) :precision binary64 (if (<= b_2 -9e-308) (/ (- b_2) a) (/ 0.0 a)))
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -9e-308) {
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 <= (-9d-308)) 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 <= -9e-308) {
tmp = -b_2 / a;
} else {
tmp = 0.0 / a;
}
return tmp;
}
def code(a, b_2, c): tmp = 0 if b_2 <= -9e-308: tmp = -b_2 / a else: tmp = 0.0 / a return tmp
function code(a, b_2, c) tmp = 0.0 if (b_2 <= -9e-308) 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 <= -9e-308) 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, -9e-308], N[((-b$95$2) / a), $MachinePrecision], N[(0.0 / a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b_2 \leq -9 \cdot 10^{-308}:\\
\;\;\;\;\frac{-b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{0}{a}\\
\end{array}
\end{array}
if b_2 < -9.00000000000000017e-308Initial program 65.1%
+-commutative65.1%
unsub-neg65.1%
Simplified65.1%
Taylor expanded in b_2 around 0 41.5%
associate-*r*41.5%
neg-mul-141.5%
*-commutative41.5%
Simplified41.5%
Taylor expanded in c around 0 21.7%
associate-*r/21.7%
neg-mul-121.7%
Simplified21.7%
if -9.00000000000000017e-308 < b_2 Initial program 35.8%
+-commutative35.8%
unsub-neg35.8%
Simplified35.8%
add-sqr-sqrt35.5%
pow235.5%
pow1/235.5%
sqrt-pow135.4%
fma-neg35.4%
*-commutative35.4%
distribute-rgt-neg-in35.4%
metadata-eval35.4%
Applied egg-rr35.4%
Taylor expanded in b_2 around inf 20.6%
distribute-rgt1-in20.6%
metadata-eval20.6%
mul0-lft20.6%
Simplified20.6%
Final simplification21.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 50.9%
+-commutative50.9%
unsub-neg50.9%
Simplified50.9%
add-sqr-sqrt50.6%
pow250.6%
pow1/250.6%
sqrt-pow150.6%
fma-neg50.6%
*-commutative50.6%
distribute-rgt-neg-in50.6%
metadata-eval50.6%
Applied egg-rr50.6%
Taylor expanded in b_2 around inf 11.5%
distribute-rgt1-in11.5%
metadata-eval11.5%
mul0-lft11.5%
Simplified11.5%
Final simplification11.5%
herbie shell --seed 2023285
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))