| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 8320 |
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \frac{b \cdot b}{\frac{1}{a + 3}}\right)\right)
\]
(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 (fma 4.0 (- (fma (* b b) (+ a 3.0) (* a a)) (pow a 3.0)) (+ (pow (hypot a b) 4.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 fma(4.0, (fma((b * b), (a + 3.0), (a * a)) - pow(a, 3.0)), (pow(hypot(a, b), 4.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 fma(4.0, Float64(fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)) - (a ^ 3.0)), Float64((hypot(a, b) ^ 4.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[(4.0 * N[(N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision] - N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision]), $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
\mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right)
Initial program 0.2
Simplified0.0
[Start]0.2 | \[ \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
\] |
|---|---|
associate--l+ [=>]0.2 | \[ \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right) - 1\right)}
\] |
+-commutative [=>]0.2 | \[ \color{blue}{\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right) - 1\right) + {\left(a \cdot a + b \cdot b\right)}^{2}}
\] |
associate-+l- [=>]0.2 | \[ \color{blue}{4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right)\right) - \left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)}
\] |
fma-neg [=>]0.2 | \[ \color{blue}{\mathsf{fma}\left(4, \left(a \cdot a\right) \cdot \left(1 - a\right) + \left(b \cdot b\right) \cdot \left(3 + a\right), -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)}
\] |
+-commutative [=>]0.2 | \[ \mathsf{fma}\left(4, \color{blue}{\left(b \cdot b\right) \cdot \left(3 + a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)}, -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
distribute-rgt-out-- [<=]0.2 | \[ \mathsf{fma}\left(4, \left(b \cdot b\right) \cdot \left(3 + a\right) + \color{blue}{\left(1 \cdot \left(a \cdot a\right) - a \cdot \left(a \cdot a\right)\right)}, -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
*-lft-identity [=>]0.2 | \[ \mathsf{fma}\left(4, \left(b \cdot b\right) \cdot \left(3 + a\right) + \left(\color{blue}{a \cdot a} - a \cdot \left(a \cdot a\right)\right), -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
associate-+r- [=>]0.2 | \[ \mathsf{fma}\left(4, \color{blue}{\left(\left(b \cdot b\right) \cdot \left(3 + a\right) + a \cdot a\right) - a \cdot \left(a \cdot a\right)}, -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
fma-def [=>]0.2 | \[ \mathsf{fma}\left(4, \color{blue}{\mathsf{fma}\left(b \cdot b, 3 + a, a \cdot a\right)} - a \cdot \left(a \cdot a\right), -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
+-commutative [=>]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, \color{blue}{a + 3}, a \cdot a\right) - a \cdot \left(a \cdot a\right), -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
cube-unmult [=>]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - \color{blue}{{a}^{3}}, -\left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)\right)
\] |
neg-sub0 [=>]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, \color{blue}{0 - \left(1 - {\left(a \cdot a + b \cdot b\right)}^{2}\right)}\right)
\] |
associate--r- [=>]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, \color{blue}{\left(0 - 1\right) + {\left(a \cdot a + b \cdot b\right)}^{2}}\right)
\] |
metadata-eval [=>]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, \color{blue}{-1} + {\left(a \cdot a + b \cdot b\right)}^{2}\right)
\] |
metadata-eval [<=]0.2 | \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, \color{blue}{\left(-1\right)} + {\left(a \cdot a + b \cdot b\right)}^{2}\right)
\] |
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 8320 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 8192 |
| Alternative 3 | |
|---|---|
| Error | 0.2 |
| Cost | 7940 |
| Alternative 4 | |
|---|---|
| Error | 0.2 |
| Cost | 7684 |
| Alternative 5 | |
|---|---|
| Error | 1.1 |
| Cost | 7680 |
| Alternative 6 | |
|---|---|
| Error | 1.6 |
| Cost | 7561 |
| Alternative 7 | |
|---|---|
| Error | 2.6 |
| Cost | 7305 |
| Alternative 8 | |
|---|---|
| Error | 2.7 |
| Cost | 7177 |
| Alternative 9 | |
|---|---|
| Error | 2.9 |
| Cost | 1092 |
| Alternative 10 | |
|---|---|
| Error | 2.9 |
| Cost | 964 |
| Alternative 11 | |
|---|---|
| Error | 12.3 |
| Cost | 704 |
| Alternative 12 | |
|---|---|
| Error | 22.7 |
| Cost | 448 |
| Alternative 13 | |
|---|---|
| Error | 23.7 |
| Cost | 64 |
herbie shell --seed 2023041
(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))