| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 14016 |
\[\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + b \cdot b\right) + {\left(\mathsf{hypot}\left(b, a\right)\right)}^{4}\right) + -1
\]
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))
(FPCore (a b) :precision binary64 (+ (+ (+ (fma 2.0 (* (* a b) (* a b)) (pow a 4.0)) (pow b 4.0)) (* 4.0 (+ (* (* a a) (+ a 1.0)) (* b b)))) -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) * (1.0 - (3.0 * a)))))) - 1.0;
}
double code(double a, double b) {
return ((fma(2.0, ((a * b) * (a * b)), pow(a, 4.0)) + pow(b, 4.0)) + (4.0 * (((a * a) * (a + 1.0)) + (b * b)))) + -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(1.0 - Float64(3.0 * a)))))) - 1.0) end
function code(a, b) return Float64(Float64(Float64(fma(2.0, Float64(Float64(a * b) * Float64(a * b)), (a ^ 4.0)) + (b ^ 4.0)) + Float64(4.0 * Float64(Float64(Float64(a * a) * Float64(a + 1.0)) + Float64(b * b)))) + -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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := N[(N[(N[(N[(2.0 * N[(N[(a * b), $MachinePrecision] * N[(a * b), $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(N[(a * a), $MachinePrecision] * N[(a + 1.0), $MachinePrecision]), $MachinePrecision] + N[(b * b), $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(1 - 3 \cdot a\right)\right)\right) - 1
\left(\left(\mathsf{fma}\left(2, \left(a \cdot b\right) \cdot \left(a \cdot b\right), {a}^{4}\right) + {b}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + b \cdot b\right)\right) + -1
Initial program 0.2
Applied egg-rr2.1
Simplified0.0
[Start]2.1 | \[ \left(\left(e^{\mathsf{log1p}\left({\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}\right)}^{2}\right)} - 1\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
|---|---|
expm1-def [=>]2.1 | \[ \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}\right)}^{2}\right)\right)} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
expm1-log1p [=>]0.2 | \[ \left(\color{blue}{{\left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}\right)}^{2}} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
unpow2 [=>]0.2 | \[ \left(\color{blue}{{\left(\mathsf{hypot}\left(b, a\right)\right)}^{2} \cdot {\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
pow-sqr [=>]0.0 | \[ \left(\color{blue}{{\left(\mathsf{hypot}\left(b, a\right)\right)}^{\left(2 \cdot 2\right)}} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
metadata-eval [=>]0.0 | \[ \left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{\color{blue}{4}} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
Taylor expanded in b around 0 0.0
Simplified0.0
[Start]0.0 | \[ \left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + \left({b}^{4} + {a}^{4}\right)\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1
\] |
|---|---|
+-commutative [=>]0.0 | \[ \left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + \color{blue}{\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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
associate-+r+ [=>]0.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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
fma-def [=>]0.0 | \[ \left(\left(\color{blue}{\mathsf{fma}\left(2, {a}^{2} \cdot {b}^{2}, {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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
unpow2 [=>]0.0 | \[ \left(\left(\mathsf{fma}\left(2, \color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}, {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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
unpow2 [=>]0.0 | \[ \left(\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
unswap-sqr [=>]0.0 | \[ \left(\left(\mathsf{fma}\left(2, \color{blue}{\left(a \cdot b\right) \cdot \left(a \cdot b\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(1 - 3 \cdot a\right)\right)\right) - 1
\] |
Taylor expanded in a around 0 0.1
Simplified0.1
[Start]0.1 | \[ \left(\left(\mathsf{fma}\left(2, \left(a \cdot b\right) \cdot \left(a \cdot b\right), {a}^{4}\right) + {b}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + {b}^{2}\right)\right) - 1
\] |
|---|---|
unpow2 [=>]0.1 | \[ \left(\left(\mathsf{fma}\left(2, \left(a \cdot b\right) \cdot \left(a \cdot b\right), {a}^{4}\right) + {b}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \color{blue}{b \cdot b}\right)\right) - 1
\] |
Final simplification0.1
| Alternative 1 | |
|---|---|
| Error | 0.1 |
| Cost | 14016 |
| Alternative 2 | |
|---|---|
| Error | 0.2 |
| Cost | 7936 |
| Alternative 3 | |
|---|---|
| Error | 1.5 |
| Cost | 7684 |
| Alternative 4 | |
|---|---|
| Error | 1.4 |
| Cost | 7680 |
| Alternative 5 | |
|---|---|
| Error | 1.6 |
| Cost | 7561 |
| Alternative 6 | |
|---|---|
| Error | 1.7 |
| Cost | 7305 |
| Alternative 7 | |
|---|---|
| Error | 1.7 |
| Cost | 1480 |
| Alternative 8 | |
|---|---|
| Error | 11.8 |
| Cost | 1216 |
| Alternative 9 | |
|---|---|
| Error | 11.8 |
| Cost | 960 |
| Alternative 10 | |
|---|---|
| Error | 11.8 |
| Cost | 704 |
| Alternative 11 | |
|---|---|
| Error | 23.6 |
| Cost | 576 |
| Alternative 12 | |
|---|---|
| Error | 12.7 |
| Cost | 576 |
| Alternative 13 | |
|---|---|
| Error | 23.7 |
| Cost | 64 |
herbie shell --seed 2023057
(FPCore (a b)
:name "Bouland and Aaronson, Equation (25)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))