| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 13504 |
\[\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + b \cdot \left(b \cdot 4\right)\right) + -1
\]
(FPCore (a b) :precision binary64 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b) :precision binary64 (+ (+ (+ (pow b 4.0) (+ (pow a 4.0) (* 2.0 (pow (* b a) 2.0)))) (* 4.0 (* 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(b, 4.0) + (pow(a, 4.0) + (2.0 * pow((b * a), 2.0)))) + (4.0 * (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 = (((b ** 4.0d0) + ((a ** 4.0d0) + (2.0d0 * ((b * a) ** 2.0d0)))) + (4.0d0 * (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(b, 4.0) + (Math.pow(a, 4.0) + (2.0 * Math.pow((b * a), 2.0)))) + (4.0 * (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(b, 4.0) + (math.pow(a, 4.0) + (2.0 * math.pow((b * a), 2.0)))) + (4.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(b * b))) - 1.0) end
function code(a, b) return Float64(Float64(Float64((b ^ 4.0) + Float64((a ^ 4.0) + Float64(2.0 * (Float64(b * a) ^ 2.0)))) + Float64(4.0 * 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 = (((b ^ 4.0) + ((a ^ 4.0) + (2.0 * ((b * a) ^ 2.0)))) + (4.0 * (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[(N[(N[Power[b, 4.0], $MachinePrecision] + N[(N[Power[a, 4.0], $MachinePrecision] + N[(2.0 * N[Power[N[(b * a), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\left(\left({b}^{4} + \left({a}^{4} + 2 \cdot {\left(b \cdot a\right)}^{2}\right)\right) + 4 \cdot \left(b \cdot b\right)\right) + -1
Results
Initial program 0.2
Taylor expanded in a around 0 0.0
Simplified0.0
[Start]0.0 | \[ \left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + \left({a}^{4} + {b}^{4}\right)\right) + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
|---|---|
+-commutative [=>]0.0 | \[ \left(\left(2 \cdot \left({a}^{2} \cdot {b}^{2}\right) + \color{blue}{\left({b}^{4} + {a}^{4}\right)}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
fma-def [=>]0.0 | \[ \left(\color{blue}{\mathsf{fma}\left(2, {a}^{2} \cdot {b}^{2}, {b}^{4} + {a}^{4}\right)} + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
unpow2 [=>]0.0 | \[ \left(\mathsf{fma}\left(2, \color{blue}{\left(a \cdot a\right)} \cdot {b}^{2}, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
unpow2 [=>]0.0 | \[ \left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \color{blue}{\left(b \cdot b\right)}, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1
\] |
Applied egg-rr0.0
Final simplification0.0
| Alternative 1 | |
|---|---|
| Error | 0.0 |
| Cost | 13504 |
| Alternative 2 | |
|---|---|
| Error | 0.1 |
| Cost | 7936 |
| Alternative 3 | |
|---|---|
| Error | 2.2 |
| Cost | 7432 |
| Alternative 4 | |
|---|---|
| Error | 0.2 |
| Cost | 7424 |
| Alternative 5 | |
|---|---|
| Error | 1.8 |
| Cost | 7305 |
| Alternative 6 | |
|---|---|
| Error | 1.7 |
| Cost | 7305 |
| Alternative 7 | |
|---|---|
| Error | 1.8 |
| Cost | 6921 |
| Alternative 8 | |
|---|---|
| Error | 1.9 |
| Cost | 1225 |
| Alternative 9 | |
|---|---|
| Error | 1.9 |
| Cost | 1225 |
| Alternative 10 | |
|---|---|
| Error | 11.8 |
| Cost | 704 |
| Alternative 11 | |
|---|---|
| Error | 12.7 |
| Cost | 576 |
| Alternative 12 | |
|---|---|
| Error | 22.8 |
| Cost | 448 |
herbie shell --seed 2023047
(FPCore (a b)
:name "Bouland and Aaronson, Equation (26)"
:precision binary64
(- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))