| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 8192 |
\[\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + -1
\]
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))
(FPCore (a b) :precision binary64 (+ (+ (+ (pow b 4.0) (fma 2.0 (* b (* a (* b a))) (pow a 4.0))) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ a 3.0))))) -1.0))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (3.0 + a))))) - 1.0;
}
double code(double a, double b) {
return ((pow(b, 4.0) + fma(2.0, (b * (a * (b * a))), pow(a, 4.0))) + (4.0 * (((a * a) * (1.0 - a)) + ((b * b) * (a + 3.0))))) + -1.0;
}
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(3.0 + a))))) - 1.0) end
function code(a, b) return Float64(Float64(Float64((b ^ 4.0) + fma(2.0, Float64(b * Float64(a * Float64(b * a))), (a ^ 4.0))) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(1.0 - a)) + Float64(Float64(b * b) * Float64(a + 3.0))))) + -1.0) end
code[a_, b_] := N[(N[(N[Power[N[(N[(a * a), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(3.0 + a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := N[(N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(2.0 * N[(b * N[(a * N[(b * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(1.0 - a), $MachinePrecision]), $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\left(\left({b}^{4} + \mathsf{fma}\left(2, b \cdot \left(a \cdot \left(b \cdot a\right)\right), {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1
Initial program 99.7%
Taylor expanded in a around 0 100.0%
Simplified100.0%
[Start]100.0 | \[ \left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + \left({a}^{4} + {b}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
|---|---|
associate-+r+ [=>]100.0 | \[ \left(\color{blue}{\left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + {a}^{4}\right) + {b}^{4}\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
+-commutative [=>]100.0 | \[ \left(\color{blue}{\left({b}^{4} + \left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + {a}^{4}\right)\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
fma-def [=>]100.0 | \[ \left(\left({b}^{4} + \color{blue}{\mathsf{fma}\left(2, {a}^{2} \cdot {b}^{2}, {a}^{4}\right)}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
unpow2 [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
unpow2 [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
swap-sqr [<=]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\right)}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
unpow2 [<=]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{{\left(a \cdot b\right)}^{2}}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
*-commutative [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, {\color{blue}{\left(b \cdot a\right)}}^{2}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
Applied egg-rr100.0%
[Start]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, {\left(b \cdot a\right)}^{2}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
|---|---|
unpow2 [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{\left(b \cdot a\right) \cdot \left(b \cdot a\right)}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
*-commutative [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \left(b \cdot a\right) \cdot \color{blue}{\left(a \cdot b\right)}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
associate-*r* [=>]100.0 | \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{\left(\left(b \cdot a\right) \cdot a\right) \cdot b}, {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right)\right) - 1
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 8192 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 7684 |
| Alternative 3 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 7680 |
| Alternative 4 | |
|---|---|
| Accuracy | 96.2% |
| Cost | 7561 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 7561 |
| Alternative 6 | |
|---|---|
| Accuracy | 96.2% |
| Cost | 7305 |
| Alternative 7 | |
|---|---|
| Accuracy | 96.1% |
| Cost | 7177 |
| Alternative 8 | |
|---|---|
| Accuracy | 95.3% |
| Cost | 6921 |
| Alternative 9 | |
|---|---|
| Accuracy | 80.7% |
| Cost | 704 |
| Alternative 10 | |
|---|---|
| Accuracy | 63.5% |
| Cost | 448 |
| Alternative 11 | |
|---|---|
| Accuracy | 62.1% |
| Cost | 64 |
herbie shell --seed 2023138
(FPCore (a b)
:name "Bouland and Aaronson, Equation (24)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (- 1.0 a)) (* (* b b) (+ 3.0 a))))) 1.0))