| Alternative 1 | |
|---|---|
| Accuracy | 84.5% |
| Cost | 7432 |
(FPCore (a b_2 c) :precision binary64 (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))
(FPCore (a b_2 c)
:precision binary64
(if (<= b_2 -1.05e-35)
(/ (* -0.5 c) b_2)
(if (<= b_2 5e+121)
(/
(-
(- b_2)
(sqrt (+ (- (* b_2 b_2) (* c a)) (* 2.0 (fma a (- c) (* c a))))))
a)
(/ (* b_2 -2.0) a))))double code(double a, double b_2, double c) {
return (-b_2 - sqrt(((b_2 * b_2) - (a * c)))) / a;
}
double code(double a, double b_2, double c) {
double tmp;
if (b_2 <= -1.05e-35) {
tmp = (-0.5 * c) / b_2;
} else if (b_2 <= 5e+121) {
tmp = (-b_2 - sqrt((((b_2 * b_2) - (c * a)) + (2.0 * fma(a, -c, (c * a)))))) / a;
} else {
tmp = (b_2 * -2.0) / a;
}
return tmp;
}
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 code(a, b_2, c) tmp = 0.0 if (b_2 <= -1.05e-35) tmp = Float64(Float64(-0.5 * c) / b_2); elseif (b_2 <= 5e+121) tmp = Float64(Float64(Float64(-b_2) - sqrt(Float64(Float64(Float64(b_2 * b_2) - Float64(c * a)) + Float64(2.0 * fma(a, Float64(-c), Float64(c * a)))))) / a); else tmp = Float64(Float64(b_2 * -2.0) / a); end return tmp 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]
code[a_, b$95$2_, c_] := If[LessEqual[b$95$2, -1.05e-35], N[(N[(-0.5 * c), $MachinePrecision] / b$95$2), $MachinePrecision], If[LessEqual[b$95$2, 5e+121], N[(N[((-b$95$2) - N[Sqrt[N[(N[(N[(b$95$2 * b$95$2), $MachinePrecision] - N[(c * a), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(a * (-c) + N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision], N[(N[(b$95$2 * -2.0), $MachinePrecision] / a), $MachinePrecision]]]
\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -1.05 \cdot 10^{-35}:\\
\;\;\;\;\frac{-0.5 \cdot c}{b_2}\\
\mathbf{elif}\;b_2 \leq 5 \cdot 10^{+121}:\\
\;\;\;\;\frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, c \cdot a\right)}}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{b_2 \cdot -2}{a}\\
\end{array}
if b_2 < -1.05e-35Initial program 14.6%
Applied egg-rr24.6%
[Start]14.6 | \[ \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
sub-neg [=>]14.6 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{b_2 \cdot b_2 + \left(-a \cdot c\right)}}}{a}
\] |
+-commutative [=>]14.6 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(-a \cdot c\right) + b_2 \cdot b_2}}}{a}
\] |
add-sqr-sqrt [=>]11.7 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\sqrt{-a \cdot c} \cdot \sqrt{-a \cdot c}} + b_2 \cdot b_2}}{a}
\] |
hypot-def [=>]24.6 | \[ \frac{\left(-b_2\right) - \color{blue}{\mathsf{hypot}\left(\sqrt{-a \cdot c}, b_2\right)}}{a}
\] |
*-commutative [=>]24.6 | \[ \frac{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{-\color{blue}{c \cdot a}}, b_2\right)}{a}
\] |
distribute-rgt-neg-in [=>]24.6 | \[ \frac{\left(-b_2\right) - \mathsf{hypot}\left(\sqrt{\color{blue}{c \cdot \left(-a\right)}}, b_2\right)}{a}
\] |
Taylor expanded in b_2 around -inf 0.0%
Simplified89.7%
[Start]0.0 | \[ 0.5 \cdot \frac{c \cdot {\left(\sqrt{-1}\right)}^{2}}{b_2}
\] |
|---|---|
associate-*r/ [=>]0.0 | \[ \color{blue}{\frac{0.5 \cdot \left(c \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{b_2}}
\] |
*-commutative [=>]0.0 | \[ \frac{0.5 \cdot \color{blue}{\left({\left(\sqrt{-1}\right)}^{2} \cdot c\right)}}{b_2}
\] |
unpow2 [=>]0.0 | \[ \frac{0.5 \cdot \left(\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot c\right)}{b_2}
\] |
rem-square-sqrt [=>]89.7 | \[ \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2}
\] |
associate-*r* [=>]89.7 | \[ \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2}
\] |
metadata-eval [=>]89.7 | \[ \frac{\color{blue}{-0.5} \cdot c}{b_2}
\] |
if -1.05e-35 < b_2 < 5.00000000000000007e121Initial program 77.9%
Applied egg-rr77.9%
[Start]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
prod-diff [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\mathsf{fma}\left(b_2, b_2, -\color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a}
\] |
fma-neg [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a}
\] |
prod-diff [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(\mathsf{fma}\left(b_2, b_2, -c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(\mathsf{fma}\left(b_2, b_2, -\color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a}
\] |
fma-neg [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}}{a}
\] |
associate-+l+ [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\color{blue}{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(-c, a, c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
fma-udef [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\color{blue}{\left(\left(-c\right) \cdot a + a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
distribute-lft-neg-in [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\color{blue}{\left(-c \cdot a\right)} + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\left(-\color{blue}{a \cdot c}\right) + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
distribute-rgt-neg-in [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\left(\color{blue}{a \cdot \left(-c\right)} + a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
fma-def [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)}}{a}
\] |
fma-udef [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \color{blue}{\left(\left(-c\right) \cdot a + a \cdot c\right)}\right)}}{a}
\] |
distribute-lft-neg-in [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\color{blue}{\left(-c \cdot a\right)} + a \cdot c\right)\right)}}{a}
\] |
*-commutative [<=]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\left(-\color{blue}{a \cdot c}\right) + a \cdot c\right)\right)}}{a}
\] |
distribute-rgt-neg-in [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \left(\color{blue}{a \cdot \left(-c\right)} + a \cdot c\right)\right)}}{a}
\] |
fma-def [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)}\right)}}{a}
\] |
Simplified77.9%
[Start]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - a \cdot c\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a}
\] |
|---|---|
*-commutative [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - \color{blue}{c \cdot a}\right) + \left(\mathsf{fma}\left(a, -c, a \cdot c\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)\right)}}{a}
\] |
count-2 [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + \color{blue}{2 \cdot \mathsf{fma}\left(a, -c, a \cdot c\right)}}}{a}
\] |
*-commutative [=>]77.9 | \[ \frac{\left(-b_2\right) - \sqrt{\left(b_2 \cdot b_2 - c \cdot a\right) + 2 \cdot \mathsf{fma}\left(a, -c, \color{blue}{c \cdot a}\right)}}{a}
\] |
if 5.00000000000000007e121 < b_2 Initial program 17.5%
Taylor expanded in b_2 around inf 95.0%
Simplified95.0%
[Start]95.0 | \[ \frac{-2 \cdot b_2}{a}
\] |
|---|---|
*-commutative [=>]95.0 | \[ \frac{\color{blue}{b_2 \cdot -2}}{a}
\] |
Final simplification84.4%
| Alternative 1 | |
|---|---|
| Accuracy | 84.5% |
| Cost | 7432 |
| Alternative 2 | |
|---|---|
| Accuracy | 79.2% |
| Cost | 7240 |
| Alternative 3 | |
|---|---|
| Accuracy | 78.7% |
| Cost | 7112 |
| Alternative 4 | |
|---|---|
| Accuracy | 43.2% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Accuracy | 43.2% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Accuracy | 64.7% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Accuracy | 16.9% |
| Cost | 388 |
| Alternative 8 | |
|---|---|
| Accuracy | 12.1% |
| Cost | 64 |
herbie shell --seed 2023151
(FPCore (a b_2 c)
:name "quad2m (problem 3.2.1, negative)"
:precision binary64
(/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))