| Alternative 1 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 7368 |
(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 -1e+131)
(+ (* -2.0 (/ b_2 a)) (* 0.5 (/ c b_2)))
(if (<= b_2 8.5e-73)
(/ (- (sqrt (+ (* b_2 b_2) (fma a (- c) (fma a (- c) (* a c))))) b_2) a)
(/ (* c -0.5) b_2))))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 <= -1e+131) {
tmp = (-2.0 * (b_2 / a)) + (0.5 * (c / b_2));
} else if (b_2 <= 8.5e-73) {
tmp = (sqrt(((b_2 * b_2) + fma(a, -c, fma(a, -c, (a * c))))) - b_2) / a;
} else {
tmp = (c * -0.5) / b_2;
}
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 <= -1e+131) tmp = Float64(Float64(-2.0 * Float64(b_2 / a)) + Float64(0.5 * Float64(c / b_2))); elseif (b_2 <= 8.5e-73) tmp = Float64(Float64(sqrt(Float64(Float64(b_2 * b_2) + fma(a, Float64(-c), fma(a, Float64(-c), 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_] := 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, -1e+131], 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, 8.5e-73], N[(N[(N[Sqrt[N[(N[(b$95$2 * b$95$2), $MachinePrecision] + N[(a * (-c) + N[(a * (-c) + N[(a * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b$95$2), $MachinePrecision] / a), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b$95$2), $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 \cdot 10^{+131}:\\
\;\;\;\;-2 \cdot \frac{b_2}{a} + 0.5 \cdot \frac{c}{b_2}\\
\mathbf{elif}\;b_2 \leq 8.5 \cdot 10^{-73}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(a, -c, a \cdot c\right)\right)} - b_2}{a}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b_2}\\
\end{array}
if b_2 < -9.9999999999999991e130Initial program 15.9%
Simplified15.9%
[Start]15.9 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]15.9 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]15.9 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Taylor expanded in b_2 around -inf 96.4%
if -9.9999999999999991e130 < b_2 < 8.4999999999999996e-73Initial program 81.0%
Simplified81.0%
[Start]81.0 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]81.0 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]81.0 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr81.0%
[Start]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}
\] |
|---|---|
prod-diff [=>]81.0 | \[ \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}
\] |
*-commutative [<=]81.0 | \[ \frac{\sqrt{\mathsf{fma}\left(b_2, b_2, -\color{blue}{a \cdot c}\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)} - b_2}{a}
\] |
fma-def [<=]81.0 | \[ \frac{\sqrt{\color{blue}{\left(b_2 \cdot b_2 + \left(-a \cdot c\right)\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)} - b_2}{a}
\] |
associate-+l+ [=>]81.0 | \[ \frac{\sqrt{\color{blue}{b_2 \cdot b_2 + \left(\left(-a \cdot c\right) + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}} - b_2}{a}
\] |
distribute-rgt-neg-in [=>]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \left(\color{blue}{a \cdot \left(-c\right)} + \mathsf{fma}\left(-c, a, c \cdot a\right)\right)} - b_2}{a}
\] |
fma-def [=>]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \color{blue}{\mathsf{fma}\left(a, -c, \mathsf{fma}\left(-c, a, c \cdot a\right)\right)}} - b_2}{a}
\] |
*-commutative [<=]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \mathsf{fma}\left(-c, a, \color{blue}{a \cdot c}\right)\right)} - b_2}{a}
\] |
fma-udef [=>]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \color{blue}{\left(-c\right) \cdot a + a \cdot c}\right)} - b_2}{a}
\] |
distribute-lft-neg-in [<=]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \color{blue}{\left(-c \cdot a\right)} + a \cdot c\right)} - b_2}{a}
\] |
*-commutative [<=]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \left(-\color{blue}{a \cdot c}\right) + a \cdot c\right)} - b_2}{a}
\] |
distribute-rgt-neg-in [=>]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \color{blue}{a \cdot \left(-c\right)} + a \cdot c\right)} - b_2}{a}
\] |
fma-def [=>]81.0 | \[ \frac{\sqrt{b_2 \cdot b_2 + \mathsf{fma}\left(a, -c, \color{blue}{\mathsf{fma}\left(a, -c, a \cdot c\right)}\right)} - b_2}{a}
\] |
if 8.4999999999999996e-73 < b_2 Initial program 17.0%
Simplified17.0%
[Start]17.0 | \[ \frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\] |
|---|---|
+-commutative [=>]17.0 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} + \left(-b_2\right)}}{a}
\] |
unsub-neg [=>]17.0 | \[ \frac{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{a}
\] |
Applied egg-rr26.0%
[Start]17.0 | \[ \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}
\] |
|---|---|
clear-num [=>]16.9 | \[ \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}
\] |
inv-pow [=>]16.9 | \[ \color{blue}{{\left(\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}\right)}^{-1}}
\] |
sub-neg [=>]16.9 | \[ {\left(\frac{a}{\sqrt{\color{blue}{b_2 \cdot b_2 + \left(-a \cdot c\right)}} - b_2}\right)}^{-1}
\] |
add-sqr-sqrt [=>]14.2 | \[ {\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 [=>]26.0 | \[ {\left(\frac{a}{\color{blue}{\mathsf{hypot}\left(b_2, \sqrt{-a \cdot c}\right)} - b_2}\right)}^{-1}
\] |
*-commutative [=>]26.0 | \[ {\left(\frac{a}{\mathsf{hypot}\left(b_2, \sqrt{-\color{blue}{c \cdot a}}\right) - b_2}\right)}^{-1}
\] |
distribute-rgt-neg-in [=>]26.0 | \[ {\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%
Simplified86.2%
[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 [=>]86.2 | \[ \frac{0.5 \cdot \left(\color{blue}{-1} \cdot c\right)}{b_2}
\] |
associate-*r* [=>]86.2 | \[ \frac{\color{blue}{\left(0.5 \cdot -1\right) \cdot c}}{b_2}
\] |
metadata-eval [=>]86.2 | \[ \frac{\color{blue}{-0.5} \cdot c}{b_2}
\] |
Final simplification85.0%
| Alternative 1 | |
|---|---|
| Accuracy | 85.1% |
| Cost | 7368 |
| Alternative 2 | |
|---|---|
| Accuracy | 79.5% |
| Cost | 7176 |
| Alternative 3 | |
|---|---|
| Accuracy | 42.7% |
| Cost | 452 |
| Alternative 4 | |
|---|---|
| Accuracy | 64.6% |
| Cost | 452 |
| Alternative 5 | |
|---|---|
| Accuracy | 64.6% |
| Cost | 452 |
| Alternative 6 | |
|---|---|
| Accuracy | 64.7% |
| Cost | 452 |
| Alternative 7 | |
|---|---|
| Accuracy | 17.1% |
| Cost | 388 |
| Alternative 8 | |
|---|---|
| Accuracy | 12.3% |
| Cost | 64 |
herbie shell --seed 2023147
(FPCore (a b_2 c)
:name "quad2p (problem 3.2.1, positive)"
:precision binary64
(/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))