| Alternative 1 | |
|---|---|
| Accuracy | 83.9% |
| Cost | 13704 |
(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 -3.3e+104)
(* -2.0 (/ b_2 a))
(if (<= b_2 1.6e-110)
(/ (- (sqrt (+ (fma b_2 b_2 (* c (- a))) (fma a (- c) (* a c)))) b_2) a)
(pow (fma 0.5 (/ a b_2) (* -2.0 (/ b_2 c))) -1.0))))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 <= -3.3e+104) {
tmp = -2.0 * (b_2 / a);
} else if (b_2 <= 1.6e-110) {
tmp = (sqrt((fma(b_2, b_2, (c * -a)) + fma(a, -c, (a * c)))) - b_2) / a;
} else {
tmp = pow(fma(0.5, (a / b_2), (-2.0 * (b_2 / c))), -1.0);
}
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 <= -3.3e+104) tmp = Float64(-2.0 * Float64(b_2 / a)); elseif (b_2 <= 1.6e-110) tmp = Float64(Float64(sqrt(Float64(fma(b_2, b_2, Float64(c * Float64(-a))) + fma(a, Float64(-c), Float64(a * c)))) - b_2) / a); else tmp = fma(0.5, Float64(a / b_2), Float64(-2.0 * Float64(b_2 / c))) ^ -1.0; 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, -3.3e+104], N[(-2.0 * N[(b$95$2 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[b$95$2, 1.6e-110], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2 + N[(c * (-a)), $MachinePrecision]), $MachinePrecision] + N[(a * (-c) + N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[Power[N[(0.5 * N[(a / b$95$2), $MachinePrecision] + N[(-2.0 * N[(b$95$2 / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], $MachinePrecision]]]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \leq -3.3 \cdot 10^{+104}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a}\\
\mathbf{elif}\;b_2 \leq 1.6 \cdot 10^{-110}:\\
\;\;\;\;\frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \mathsf{fma}\left(a, -c, a \cdot c\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;{\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, -2 \cdot \frac{b_2}{c}\right)\right)}^{-1}\\
\end{array}
if b_2 < -3.29999999999999985e104Initial program 28.7%
Simplified28.7%
[Start]28.7 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]28.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]28.7 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around -inf 95.1%
if -3.29999999999999985e104 < b_2 < 1.60000000000000014e-110Initial program 81.6%
Simplified81.6%
[Start]81.6 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]81.6 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]81.6 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr81.6%
[Start]81.6 | \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}
\] |
|---|---|
prod-diff [=>]81.6 | \[ \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b_2, b_2, -c \cdot a\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)}} - b_2}{a}
\] |
distribute-rgt-neg-in [=>]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, \color{blue}{c \cdot \left(-a\right)}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)} - b_2}{a}
\] |
*-commutative [<=]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)} - b_2}{a}
\] |
fma-udef [=>]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \color{blue}{\left(\left(-c\right) \cdot a + a \cdot c\right)}} - b_2}{a}
\] |
distribute-lft-neg-in [<=]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \left(\color{blue}{\left(-c \cdot a\right)} + a \cdot c\right)} - b_2}{a}
\] |
*-commutative [<=]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \left(\left(-\color{blue}{a \cdot c}\right) + a \cdot c\right)} - b_2}{a}
\] |
distribute-rgt-neg-in [=>]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \left(\color{blue}{a \cdot \left(-c\right)} + a \cdot c\right)} - b_2}{a}
\] |
fma-def [=>]81.6 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, c \cdot \left(-a\right)\right) + \color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)}} - b_2}{a}
\] |
if 1.60000000000000014e-110 < b_2 Initial program 20.6%
Simplified20.6%
[Start]20.6 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]20.6 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]20.6 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr28.2%
[Start]20.6 | \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}
\] |
|---|---|
clear-num [=>]20.6 | \[ \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}
\] |
inv-pow [=>]20.6 | \[ \color{blue}{{\left(\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\right)}^{-1}}
\] |
sub-neg [=>]20.6 | \[ {\left(\frac{a}{\sqrt{\color{blue}{b_2 \cdot b_2 + \left(-a \cdot c\right)}} - b_2}\right)}^{-1}
\] |
add-sqr-sqrt [=>]17.5 | \[ {\left(\frac{a}{\sqrt{b_2 \cdot b_2 + \color{blue}{\sqrt{-a \cdot c} \cdot \sqrt{-a \cdot c}}} - b_2}\right)}^{-1}
\] |
hypot-def [=>]28.2 | \[ {\left(\frac{a}{\color{blue}{\mathsf{hypot}\left(b_2, \sqrt{-a \cdot c}\right)} - b_2}\right)}^{-1}
\] |
*-commutative [=>]28.2 | \[ {\left(\frac{a}{\mathsf{hypot}\left(b_2, \sqrt{-\color{blue}{c \cdot a}}\right) - b_2}\right)}^{-1}
\] |
distribute-rgt-neg-in [=>]28.2 | \[ {\left(\frac{a}{\mathsf{hypot}\left(b_2, \sqrt{\color{blue}{c \cdot \left(-a\right)}}\right) - b_2}\right)}^{-1}
\] |
Taylor expanded in b_2 around inf 0.0%
Simplified82.2%
[Start]0.0 | \[ {\left(0.5 \cdot \frac{a}{b_2} + 2 \cdot \frac{b_2}{c \cdot {\left(\sqrt{-1}\right)}^{2}}\right)}^{-1}
\] |
|---|---|
fma-def [=>]0.0 | \[ {\color{blue}{\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, 2 \cdot \frac{b_2}{c \cdot {\left(\sqrt{-1}\right)}^{2}}\right)\right)}}^{-1}
\] |
associate-*r/ [=>]0.0 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \color{blue}{\frac{2 \cdot b_2}{c \cdot {\left(\sqrt{-1}\right)}^{2}}}\right)\right)}^{-1}
\] |
*-commutative [=>]0.0 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2 \cdot b_2}{\color{blue}{{\left(\sqrt{-1}\right)}^{2} \cdot c}}\right)\right)}^{-1}
\] |
unpow2 [=>]0.0 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2 \cdot b_2}{\color{blue}{\left(\sqrt{-1} \cdot \sqrt{-1}\right)} \cdot c}\right)\right)}^{-1}
\] |
rem-square-sqrt [=>]82.2 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \frac{2 \cdot b_2}{\color{blue}{-1} \cdot c}\right)\right)}^{-1}
\] |
times-frac [=>]82.2 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \color{blue}{\frac{2}{-1} \cdot \frac{b_2}{c}}\right)\right)}^{-1}
\] |
metadata-eval [=>]82.2 | \[ {\left(\mathsf{fma}\left(0.5, \frac{a}{b_2}, \color{blue}{-2} \cdot \frac{b_2}{c}\right)\right)}^{-1}
\] |
Final simplification83.9%
| Alternative 1 | |
|---|---|
| Accuracy | 83.9% |
| Cost | 13704 |
| Alternative 2 | |
|---|---|
| Accuracy | 84.0% |
| Cost | 7368 |
| Alternative 3 | |
|---|---|
| Accuracy | 78.8% |
| Cost | 7176 |
| Alternative 4 | |
|---|---|
| Accuracy | 64.0% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Accuracy | 29.0% |
| Cost | 320 |
herbie shell --seed 2023151
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))