?

Average Error: 0.2 → 0.0
Time: 11.2s
Precision: binary64
Cost: 21312

?

\[\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, a \cdot \left(b \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 \]
(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 (* a (* b (* 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, (a * (b * (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(a * Float64(b * 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[(a * N[(b * 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, a \cdot \left(b \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

Error?

Derivation?

  1. Initial program 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 \]
  2. Applied egg-rr0.2

    \[\leadsto \left(\color{blue}{\mathsf{hypot}\left(b, a\right) \cdot \left(\mathsf{hypot}\left(b, a\right) \cdot {\left(\mathsf{hypot}\left(b, a\right)\right)}^{2}\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 \]
  3. Taylor expanded in b around 0 0.0

    \[\leadsto \left(\color{blue}{\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(3 + a\right)\right)\right) - 1 \]
  4. Simplified0.0

    \[\leadsto \left(\color{blue}{\left({b}^{4} + \mathsf{fma}\left(2, a \cdot \left(b \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(3 + a\right)\right)\right) - 1 \]
    Proof

    [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(3 + a\right)\right)\right) - 1 \]

    +-commutative [=>]0.0

    \[ \left(\color{blue}{\left(\left({b}^{4} + {a}^{4}\right) + 2 \cdot \left({a}^{2} \cdot {b}^{2}\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-+l+ [=>]0.0

    \[ \left(\color{blue}{\left({b}^{4} + \left({a}^{4} + 2 \cdot \left({a}^{2} \cdot {b}^{2}\right)\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 [<=]0.0

    \[ \left(\left({b}^{4} + \color{blue}{\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 [=>]0.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 [=>]0.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 \]

    associate-*l* [=>]0.0

    \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, \color{blue}{a \cdot \left(a \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 \]

    *-commutative [<=]0.0

    \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, a \cdot \color{blue}{\left({b}^{2} \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 \]

    unpow2 [=>]0.0

    \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, a \cdot \left(\color{blue}{\left(b \cdot b\right)} \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 \]

    associate-*l* [=>]0.0

    \[ \left(\left({b}^{4} + \mathsf{fma}\left(2, a \cdot \color{blue}{\left(b \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(3 + a\right)\right)\right) - 1 \]
  5. Final simplification0.0

    \[\leadsto \left(\left({b}^{4} + \mathsf{fma}\left(2, a \cdot \left(b \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 \]

Alternatives

Alternative 1
Error0.2
Cost8576
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \frac{b}{\frac{3 - a}{b}} \cdot \left(9 - a \cdot a\right)\right)\right) + -1 \]
Alternative 2
Error0.6
Cost8328
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \mathbf{elif}\;b \cdot b \leq 10000000000:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + 4 \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot a\right) + a \cdot a\right)\right) + -1\\ \end{array} \]
Alternative 3
Error0.2
Cost8192
\[\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 \]
Alternative 4
Error1.3
Cost8064
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot \left(b \cdot a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) + -1 \]
Alternative 5
Error1.5
Cost7936
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1 \]
Alternative 6
Error1.9
Cost7560
\[\begin{array}{l} \mathbf{if}\;a \leq -8.4 \cdot 10^{-7}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot \left(b \cdot a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\right) + -1\\ \mathbf{elif}\;a \leq 5 \cdot 10^{-8}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(12 + 4 \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \end{array} \]
Alternative 7
Error1.8
Cost7560
\[\begin{array}{l} \mathbf{if}\;a \leq -6.5 \cdot 10^{-7}:\\ \;\;\;\;\left(4 \cdot \left(b \cdot \left(b \cdot a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\right) + -1\\ \mathbf{elif}\;a \leq 1.55 \cdot 10^{-8}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + 4 \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \end{array} \]
Alternative 8
Error1.9
Cost2249
\[\begin{array}{l} \mathbf{if}\;a \leq -1.85 \cdot 10^{-6} \lor \neg \left(a \leq 3.4 \cdot 10^{-8}\right):\\ \;\;\;\;\left(4 \cdot \left(b \cdot \left(b \cdot a\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(12 + 4 \cdot a\right)\right) + -1\\ \end{array} \]
Alternative 9
Error3.3
Cost2121
\[\begin{array}{l} \mathbf{if}\;a \leq -400000000000 \lor \neg \left(a \leq 5 \cdot 10^{-8}\right):\\ \;\;\;\;\left(4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(a + 3\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(12 + 4 \cdot a\right)\right) + -1\\ \end{array} \]
Alternative 10
Error12.0
Cost960
\[\left(b \cdot b\right) \cdot \left(b \cdot b + \left(12 + 4 \cdot a\right)\right) + -1 \]
Alternative 11
Error13.1
Cost576
\[\left(b \cdot b\right) \cdot \left(b \cdot b\right) + -1 \]
Alternative 12
Error23.3
Cost448
\[b \cdot \left(b \cdot 12\right) + -1 \]

Error

Reproduce?

herbie shell --seed 2023037 
(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))