| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 14016 |
\[\frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{a \cdot 3}
\]
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c) :precision binary64 (/ (/ (* c (* a -3.0)) (+ b (sqrt (fma c (* a -3.0) (* b b))))) (* a 3.0)))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
return ((c * (a * -3.0)) / (b + sqrt(fma(c, (a * -3.0), (b * b))))) / (a * 3.0);
}
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function code(a, b, c) return Float64(Float64(Float64(c * Float64(a * -3.0)) / Float64(b + sqrt(fma(c, Float64(a * -3.0), Float64(b * b))))) / Float64(a * 3.0)) end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(c * N[(a * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\frac{\frac{c \cdot \left(a \cdot -3\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{a \cdot 3}
Initial program 18.2%
Applied egg-rr18.7%
[Start]18.2 | \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\] |
|---|---|
+-commutative [=>]18.2 | \[ \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}}{3 \cdot a}
\] |
flip-+ [=>]18.2 | \[ \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} \cdot \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}}{3 \cdot a}
\] |
add-sqr-sqrt [<=]18.7 | \[ \frac{\frac{\color{blue}{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right)} - \left(-b\right) \cdot \left(-b\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
sqr-neg [=>]18.7 | \[ \frac{\frac{\left(b \cdot b - \left(3 \cdot a\right) \cdot c\right) - \color{blue}{b \cdot b}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
associate--l- [=>]18.7 | \[ \frac{\frac{\color{blue}{b \cdot b - \left(\left(3 \cdot a\right) \cdot c + b \cdot b\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
+-commutative [<=]18.7 | \[ \frac{\frac{b \cdot b - \color{blue}{\left(b \cdot b + \left(3 \cdot a\right) \cdot c\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
fma-def [=>]18.7 | \[ \frac{\frac{b \cdot b - \color{blue}{\mathsf{fma}\left(b, b, \left(3 \cdot a\right) \cdot c\right)}}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
associate-*l* [=>]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \color{blue}{3 \cdot \left(a \cdot c\right)}\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \left(-b\right)}}{3 \cdot a}
\] |
add-sqr-sqrt [=>]0.0 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{\sqrt{-b} \cdot \sqrt{-b}}}}{3 \cdot a}
\] |
sqrt-unprod [=>]0.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{\sqrt{\left(-b\right) \cdot \left(-b\right)}}}}{3 \cdot a}
\] |
sqr-neg [=>]0.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \sqrt{\color{blue}{b \cdot b}}}}{3 \cdot a}
\] |
sqrt-prod [=>]1.6 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{\sqrt{b} \cdot \sqrt{b}}}}{3 \cdot a}
\] |
add-sqr-sqrt [<=]0.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - \color{blue}{b}}}{3 \cdot a}
\] |
unsub-neg [<=]0.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(-b\right)}}}{3 \cdot a}
\] |
+-commutative [<=]0.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{\color{blue}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}
\] |
Simplified18.7%
[Start]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
|---|---|
fma-udef [=>]18.7 | \[ \frac{\frac{b \cdot b - \color{blue}{\left(b \cdot b + 3 \cdot \left(a \cdot c\right)\right)}}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
fma-udef [<=]18.7 | \[ \frac{\frac{b \cdot b - \color{blue}{\mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
associate-*r* [=>]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \color{blue}{\left(3 \cdot a\right) \cdot c}\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
*-commutative [=>]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \color{blue}{\left(a \cdot 3\right)} \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
fma-def [<=]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(a \cdot 3\right) \cdot c\right)}{b + \sqrt{\color{blue}{b \cdot b + c \cdot \left(a \cdot -3\right)}}}}{3 \cdot a}
\] |
+-commutative [=>]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(a \cdot 3\right) \cdot c\right)}{b + \sqrt{\color{blue}{c \cdot \left(a \cdot -3\right) + b \cdot b}}}}{3 \cdot a}
\] |
fma-def [=>]18.7 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \left(a \cdot 3\right) \cdot c\right)}{b + \sqrt{\color{blue}{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}}{3 \cdot a}
\] |
Taylor expanded in b around 0 99.2%
Simplified99.4%
[Start]99.2 | \[ \frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{3 \cdot a}
\] |
|---|---|
*-commutative [=>]99.2 | \[ \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot -3}}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{3 \cdot a}
\] |
associate-*l* [=>]99.4 | \[ \frac{\frac{\color{blue}{c \cdot \left(a \cdot -3\right)}}{b + \sqrt{\mathsf{fma}\left(c, a \cdot -3, b \cdot b\right)}}}{3 \cdot a}
\] |
Final simplification99.4%
| Alternative 1 | |
|---|---|
| Accuracy | 99.2% |
| Cost | 14016 |
| Alternative 2 | |
|---|---|
| Accuracy | 95.2% |
| Cost | 7488 |
| Alternative 3 | |
|---|---|
| Accuracy | 94.7% |
| Cost | 1344 |
| Alternative 4 | |
|---|---|
| Accuracy | 94.9% |
| Cost | 1344 |
| Alternative 5 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 320 |
| Alternative 6 | |
|---|---|
| Accuracy | 89.8% |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Accuracy | 90.2% |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Accuracy | 3.3% |
| Cost | 64 |
herbie shell --seed 2023138
(FPCore (a b c)
:name "Cubic critical, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))