?

Average Error: 0.2 → 0.1
Time: 9.1s
Precision: binary64
Cost: 20928

?

\[\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(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\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
 (+
  (fma
   (* b b)
   (+ 12.0 (* 2.0 (* a a)))
   (+ (+ (pow a 4.0) (pow b 4.0)) (* 4.0 (* a (* a (- 1.0 a))))))
  -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((b * b), (12.0 + (2.0 * (a * a))), ((pow(a, 4.0) + pow(b, 4.0)) + (4.0 * (a * (a * (1.0 - a)))))) + -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(fma(Float64(b * b), Float64(12.0 + Float64(2.0 * Float64(a * a))), Float64(Float64((a ^ 4.0) + (b ^ 4.0)) + Float64(4.0 * Float64(a * Float64(a * Float64(1.0 - a)))))) + -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[(b * b), $MachinePrecision] * N[(12.0 + N[(2.0 * N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[a, 4.0], $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(a * N[(a * N[(1.0 - a), $MachinePrecision]), $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
\mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\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. Taylor expanded in a around 0 0.0

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

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

    fma-def [=>]0.0

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

    swap-sqr [<=]0.0

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

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

    \[\leadsto \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \color{blue}{3 \cdot {b}^{2}}\right)\right) - 1 \]
  6. Simplified0.1

    \[\leadsto \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \color{blue}{b \cdot \left(b \cdot 3\right)}\right)\right) - 1 \]
    Proof

    [Start]0.1

    \[ \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + 3 \cdot {b}^{2}\right)\right) - 1 \]

    *-commutative [=>]0.1

    \[ \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \color{blue}{{b}^{2} \cdot 3}\right)\right) - 1 \]

    unpow2 [=>]0.1

    \[ \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \color{blue}{\left(b \cdot b\right)} \cdot 3\right)\right) - 1 \]

    associate-*r* [<=]0.1

    \[ \left(\mathsf{fma}\left(2, \left(\left(b \cdot a\right) \cdot a\right) \cdot b, {b}^{4} + {a}^{4}\right) + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + \color{blue}{b \cdot \left(b \cdot 3\right)}\right)\right) - 1 \]
  7. Taylor expanded in b around 0 0.1

    \[\leadsto \color{blue}{\left({b}^{2} \cdot \left(12 + 2 \cdot {a}^{2}\right) + \left({b}^{4} + \left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right)\right)} - 1 \]
  8. Simplified0.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right)} - 1 \]
    Proof

    [Start]0.1

    \[ \left({b}^{2} \cdot \left(12 + 2 \cdot {a}^{2}\right) + \left({b}^{4} + \left({a}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right)\right) - 1 \]

    associate-+r+ [=>]0.1

    \[ \left({b}^{2} \cdot \left(12 + 2 \cdot {a}^{2}\right) + \color{blue}{\left(\left({b}^{4} + {a}^{4}\right) + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)}\right) - 1 \]

    +-commutative [<=]0.1

    \[ \left({b}^{2} \cdot \left(12 + 2 \cdot {a}^{2}\right) + \left(\color{blue}{\left({a}^{4} + {b}^{4}\right)} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right) - 1 \]

    associate-+r+ [<=]0.1

    \[ \left({b}^{2} \cdot \left(12 + 2 \cdot {a}^{2}\right) + \color{blue}{\left({a}^{4} + \left({b}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right)}\right) - 1 \]

    fma-def [=>]0.1

    \[ \color{blue}{\mathsf{fma}\left({b}^{2}, 12 + 2 \cdot {a}^{2}, {a}^{4} + \left({b}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right)} - 1 \]

    unpow2 [=>]0.1

    \[ \mathsf{fma}\left(\color{blue}{b \cdot b}, 12 + 2 \cdot {a}^{2}, {a}^{4} + \left({b}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right) - 1 \]

    unpow2 [=>]0.1

    \[ \mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \color{blue}{\left(a \cdot a\right)}, {a}^{4} + \left({b}^{4} + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)\right)\right) - 1 \]

    associate-+r+ [=>]0.1

    \[ \mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \color{blue}{\left({a}^{4} + {b}^{4}\right) + 4 \cdot \left({a}^{2} \cdot \left(1 - a\right)\right)}\right) - 1 \]

    unpow2 [=>]0.1

    \[ \mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \left(\color{blue}{\left(a \cdot a\right)} \cdot \left(1 - a\right)\right)\right) - 1 \]

    associate-*r* [<=]0.1

    \[ \mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \color{blue}{\left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)}\right) - 1 \]
  9. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(b \cdot b, 12 + 2 \cdot \left(a \cdot a\right), \left({a}^{4} + {b}^{4}\right) + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1 \]

Alternatives

Alternative 1
Error0.2
Cost8068
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + b \cdot \left(b \cdot 3\right)\right)\right) + -1\\ \end{array} \]
Alternative 2
Error0.2
Cost8064
\[\left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + b \cdot \left(b \cdot 3\right)\right)\right) + -1 \]
Alternative 3
Error1.5
Cost7561
\[\begin{array}{l} \mathbf{if}\;b \leq -5.3 \cdot 10^{-8} \lor \neg \left(b \leq 8.5 \cdot 10^{-11}\right):\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\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 4
Error1.7
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-23}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(a \cdot \left(a \cdot \left(1 - a\right)\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(12 + a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 5
Error2.5
Cost7433
\[\begin{array}{l} \mathbf{if}\;b \leq -1.9 \cdot 10^{-8} \lor \neg \left(b \leq 8.5 \cdot 10^{-11}\right):\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + -4 \cdot \left(a \cdot \left(a \cdot a\right)\right)\right) + -1\\ \end{array} \]
Alternative 6
Error2.5
Cost7305
\[\begin{array}{l} \mathbf{if}\;b \leq -1.7 \cdot 10^{-8} \lor \neg \left(b \leq 8.5 \cdot 10^{-11}\right):\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \end{array} \]
Alternative 7
Error2.6
Cost7241
\[\begin{array}{l} \mathbf{if}\;b \leq -5 \cdot 10^{-9} \lor \neg \left(b \leq 8.5 \cdot 10^{-11}\right):\\ \;\;\;\;\left(b \cdot b\right) \cdot \mathsf{fma}\left(b, b, 12\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \end{array} \]
Alternative 8
Error3.3
Cost7176
\[\begin{array}{l} \mathbf{if}\;b \leq -0.34:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \leq 1.15:\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 9
Error3.3
Cost6792
\[\begin{array}{l} \mathbf{if}\;b \leq -0.38:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \leq 9.2:\\ \;\;\;\;\left(a + -4\right) \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 10
Error13.0
Cost969
\[\begin{array}{l} \mathbf{if}\;a \leq -4.8 \lor \neg \left(a \leq 2.45\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot \left(a \cdot \left(4 \cdot \left(1 - a\right)\right)\right) + -1\\ \end{array} \]
Alternative 11
Error13.2
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -0.42 \lor \neg \left(a \leq 2.45\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1\\ \end{array} \]
Alternative 12
Error13.1
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -1.95 \lor \neg \left(a \leq 1.1\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot 4 + -1\\ \end{array} \]
Alternative 13
Error12.8
Cost704
\[\left(a + -4\right) \cdot \left(a \cdot \left(a \cdot a\right)\right) + -1 \]
Alternative 14
Error23.5
Cost64
\[-1 \]

Error

Reproduce?

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