?

Average Error: 0.3% → 0.04%
Time: 10.1s
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(\mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {b}^{4}\right) + {a}^{4}\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
 (+
  (+
   (+ (fma 2.0 (* (* b b) (* a a)) (pow b 4.0)) (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 ((fma(2.0, ((b * b) * (a * a)), pow(b, 4.0)) + 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(fma(2.0, Float64(Float64(b * b) * Float64(a * a)), (b ^ 4.0)) + (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[(2.0 * N[(N[(b * b), $MachinePrecision] * N[(a * a), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $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(\mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {b}^{4}\right) + {a}^{4}\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.3

    \[\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.04

    \[\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.04

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

    \[ \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 \]

    +-commutative [=>]0.04

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

    associate-+r+ [=>]0.04

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

    fma-def [=>]0.04

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

    *-commutative [=>]0.04

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

    unpow2 [=>]0.04

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

    unpow2 [=>]0.04

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

    \[\leadsto \left(\left(\mathsf{fma}\left(2, \left(b \cdot b\right) \cdot \left(a \cdot a\right), {b}^{4}\right) + {a}^{4}\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.3%
Cost8196
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-44}:\\ \;\;\;\;\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 + \left(b \cdot b\right) \cdot \left(a + 3\right)\right)\right) + -1\\ \end{array} \]
Alternative 2
Error0.3%
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(b \cdot b + a \cdot a\right)}^{2}\right) + -1 \]
Alternative 3
Error2.88%
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -0.0005 \lor \neg \left(a \leq 1.2 \cdot 10^{-25}\right):\\ \;\;\;\;\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 12\right) + -1\\ \end{array} \]
Alternative 4
Error2.87%
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -0.0005 \lor \neg \left(a \leq 1.2 \cdot 10^{-25}\right):\\ \;\;\;\;\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
Error3.54%
Cost7433
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275 \lor \neg \left(a \leq 4.2\right):\\ \;\;\;\;\left({a}^{4} + -4 \cdot \left(a \cdot \left(a \cdot a\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \end{array} \]
Alternative 6
Error4.42%
Cost7304
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275:\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \mathbf{elif}\;a \leq 1.2 \cdot 10^{-25}:\\ \;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + a \cdot \left(a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 7
Error4.36%
Cost7304
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275:\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \mathbf{elif}\;a \leq 4 \cdot 10^{-26}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 12\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + a \cdot \left(a \cdot 4\right)\right) + -1\\ \end{array} \]
Alternative 8
Error3.66%
Cost7241
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275 \lor \neg \left(a \leq 5.5\right):\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right) + -1\\ \end{array} \]
Alternative 9
Error3.7%
Cost7177
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275 \lor \neg \left(a \leq 4.2\right):\\ \;\;\;\;{a}^{3} \cdot \left(a + -4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) + -1\\ \end{array} \]
Alternative 10
Error4.87%
Cost6921
\[\begin{array}{l} \mathbf{if}\;a \leq -0.00275 \lor \neg \left(a \leq 1.2 \cdot 10^{-25}\right):\\ \;\;\;\;{a}^{4} + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) + -1\\ \end{array} \]
Alternative 11
Error18.9%
Cost704
\[\left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) + -1 \]
Alternative 12
Error35.48%
Cost448
\[\left(a \cdot a\right) \cdot 4 + -1 \]
Alternative 13
Error35.35%
Cost448
\[\left(b \cdot b\right) \cdot 12 + -1 \]

Error

Reproduce?

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