| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 14016 |
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b) :precision binary64 (+ (pow a 4.0) (+ (+ (pow b 4.0) (* (+ 4.0 (* 2.0 (* a a))) (* b b))) -1.0)))
double code(double a, double b) {
return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
double code(double a, double b) {
return pow(a, 4.0) + ((pow(b, 4.0) + ((4.0 + (2.0 * (a * a))) * (b * b))) + -1.0);
}
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((a * a) + (b * b)) ** 2.0d0) + (4.0d0 * (b * b))) - 1.0d0
end function
real(8) function code(a, b)
real(8), intent (in) :: a
real(8), intent (in) :: b
code = (a ** 4.0d0) + (((b ** 4.0d0) + ((4.0d0 + (2.0d0 * (a * a))) * (b * b))) + (-1.0d0))
end function
public static double code(double a, double b) {
return (Math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
public static double code(double a, double b) {
return Math.pow(a, 4.0) + ((Math.pow(b, 4.0) + ((4.0 + (2.0 * (a * a))) * (b * b))) + -1.0);
}
def code(a, b): return (math.pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0
def code(a, b): return math.pow(a, 4.0) + ((math.pow(b, 4.0) + ((4.0 + (2.0 * (a * a))) * (b * b))) + -1.0)
function code(a, b) return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0) end
function code(a, b) return Float64((a ^ 4.0) + Float64(Float64((b ^ 4.0) + Float64(Float64(4.0 + Float64(2.0 * Float64(a * a))) * Float64(b * b))) + -1.0)) end
function tmp = code(a, b) tmp = ((((a * a) + (b * b)) ^ 2.0) + (4.0 * (b * b))) - 1.0; end
function tmp = code(a, b) tmp = (a ^ 4.0) + (((b ^ 4.0) + ((4.0 + (2.0 * (a * a))) * (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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := N[(N[Power[a, 4.0], $MachinePrecision] + N[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[(4.0 + N[(2.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
{a}^{4} + \left(\left({b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)\right) + -1\right)
Results
Initial program 99.7%
Simplified99.7%
[Start]99.7 | \[ \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
|---|---|
associate--l+ [=>]99.7 | \[ \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)}
\] |
fma-def [=>]99.7 | \[ {\color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)
\] |
*-commutative [=>]99.7 | \[ {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(\color{blue}{\left(b \cdot b\right) \cdot 4} - 1\right)
\] |
Applied egg-rr99.7%
[Start]99.7 | \[ {\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
|---|---|
unpow2 [=>]99.7 | \[ \color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right) \cdot \mathsf{fma}\left(a, a, b \cdot b\right)} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
fma-udef [=>]99.7 | \[ \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \color{blue}{\left(a \cdot a + b \cdot b\right)} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
distribute-lft-in [=>]99.7 | \[ \color{blue}{\left(\mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(a \cdot a\right) + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right)} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
add-sqr-sqrt [=>]99.7 | \[ \left(\color{blue}{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)} \cdot \left(a \cdot a\right) + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow2 [=>]99.7 | \[ \left(\color{blue}{{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{2}} \cdot \left(a \cdot a\right) + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow2 [=>]99.7 | \[ \left({\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{2} \cdot \color{blue}{{a}^{2}} + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow-prod-down [=>]99.7 | \[ \left(\color{blue}{{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot a\right)}^{2}} + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
fma-udef [=>]99.7 | \[ \left({\left(\sqrt{\color{blue}{a \cdot a + b \cdot b}} \cdot a\right)}^{2} + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
hypot-def [=>]99.7 | \[ \left({\left(\color{blue}{\mathsf{hypot}\left(a, b\right)} \cdot a\right)}^{2} + \mathsf{fma}\left(a, a, b \cdot b\right) \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
add-sqr-sqrt [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)} \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow2 [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + \color{blue}{{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{2}} \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow2 [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + {\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{2} \cdot \color{blue}{{b}^{2}}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
pow-prod-down [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + \color{blue}{{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot b\right)}^{2}}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
fma-udef [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + {\left(\sqrt{\color{blue}{a \cdot a + b \cdot b}} \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
hypot-def [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + {\left(\color{blue}{\mathsf{hypot}\left(a, b\right)} \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
Simplified99.7%
[Start]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right) \cdot a\right)}^{2} + {\left(\mathsf{hypot}\left(a, b\right) \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
|---|---|
unpow2 [=>]99.7 | \[ \left(\color{blue}{\left(\mathsf{hypot}\left(a, b\right) \cdot a\right) \cdot \left(\mathsf{hypot}\left(a, b\right) \cdot a\right)} + {\left(\mathsf{hypot}\left(a, b\right) \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
swap-sqr [=>]99.7 | \[ \left(\color{blue}{\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right) \cdot \left(a \cdot a\right)} + {\left(\mathsf{hypot}\left(a, b\right) \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
unpow2 [<=]99.7 | \[ \left(\color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}} \cdot \left(a \cdot a\right) + {\left(\mathsf{hypot}\left(a, b\right) \cdot b\right)}^{2}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
unpow2 [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a\right) + \color{blue}{\left(\mathsf{hypot}\left(a, b\right) \cdot b\right) \cdot \left(\mathsf{hypot}\left(a, b\right) \cdot b\right)}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
swap-sqr [=>]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a\right) + \color{blue}{\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right) \cdot \left(b \cdot b\right)}\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
unpow2 [<=]99.7 | \[ \left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a\right) + \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2}} \cdot \left(b \cdot b\right)\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
distribute-lft-out [=>]99.7 | \[ \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a + b \cdot b\right)} + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
Applied egg-rr99.7%
[Start]99.7 | \[ {\left(\mathsf{hypot}\left(a, b\right)\right)}^{2} \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
|---|---|
unpow2 [=>]99.7 | \[ \color{blue}{\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right)} \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
hypot-udef [=>]99.7 | \[ \left(\color{blue}{\sqrt{a \cdot a + b \cdot b}} \cdot \mathsf{hypot}\left(a, b\right)\right) \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
hypot-udef [=>]99.7 | \[ \left(\sqrt{a \cdot a + b \cdot b} \cdot \color{blue}{\sqrt{a \cdot a + b \cdot b}}\right) \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
add-sqr-sqrt [<=]99.7 | \[ \color{blue}{\left(a \cdot a + b \cdot b\right)} \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
+-commutative [=>]99.7 | \[ \color{blue}{\left(b \cdot b + a \cdot a\right)} \cdot \left(a \cdot a + b \cdot b\right) + \left(\left(b \cdot b\right) \cdot 4 - 1\right)
\] |
Taylor expanded in b around 0 100.0%
Simplified100.0%
[Start]100.0 | \[ \left({b}^{4} + \left({a}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}\right)\right) - 1
\] |
|---|---|
associate-+r+ [=>]100.0 | \[ \color{blue}{\left(\left({b}^{4} + {a}^{4}\right) + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}\right)} - 1
\] |
+-commutative [<=]100.0 | \[ \left(\color{blue}{\left({a}^{4} + {b}^{4}\right)} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}\right) - 1
\] |
associate-+r+ [<=]100.0 | \[ \color{blue}{\left({a}^{4} + \left({b}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}\right)\right)} - 1
\] |
associate--l+ [=>]100.0 | \[ \color{blue}{{a}^{4} + \left(\left({b}^{4} + \left(4 + 2 \cdot {a}^{2}\right) \cdot {b}^{2}\right) - 1\right)}
\] |
unpow2 [=>]100.0 | \[ {a}^{4} + \left(\left({b}^{4} + \left(4 + 2 \cdot \color{blue}{\left(a \cdot a\right)}\right) \cdot {b}^{2}\right) - 1\right)
\] |
unpow2 [=>]100.0 | \[ {a}^{4} + \left(\left({b}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \color{blue}{\left(b \cdot b\right)}\right) - 1\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 14016 |
| Alternative 2 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 7744 |
| Alternative 3 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 7424 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.2% |
| Cost | 1481 |
| Alternative 5 | |
|---|---|
| Accuracy | 99.7% |
| Cost | 1472 |
| Alternative 6 | |
|---|---|
| Accuracy | 97.1% |
| Cost | 1225 |
| Alternative 7 | |
|---|---|
| Accuracy | 97.1% |
| Cost | 1225 |
| Alternative 8 | |
|---|---|
| Accuracy | 81.6% |
| Cost | 704 |
| Alternative 9 | |
|---|---|
| Accuracy | 80.3% |
| Cost | 576 |
| Alternative 10 | |
|---|---|
| Accuracy | 64.9% |
| Cost | 448 |
herbie shell --seed 2023146
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))