?

Average Error: 0.28% → 0.08%
Time: 10.9s
Precision: binary64
Cost: 21056

?

\[\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(1 - 3 \cdot a\right)\right)\right) - 1 \]
\[\left(\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {b}^{4}\right) + {a}^{4}\right) + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\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) (- 1.0 (* 3.0 a))))))
  1.0))
(FPCore (a b)
 :precision binary64
 (+
  (+
   (+ (fma 2.0 (* (* a a) (* b b)) (pow b 4.0)) (pow a 4.0))
   (* 4.0 (+ (* b b) (* (* a a) (+ a 1.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) * (1.0 - (3.0 * a)))))) - 1.0;
}
double code(double a, double b) {
	return ((fma(2.0, ((a * a) * (b * b)), pow(b, 4.0)) + pow(a, 4.0)) + (4.0 * ((b * b) + ((a * a) * (a + 1.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(1.0 - Float64(3.0 * a)))))) - 1.0)
end
function code(a, b)
	return Float64(Float64(Float64(fma(2.0, Float64(Float64(a * a) * Float64(b * b)), (b ^ 4.0)) + (a ^ 4.0)) + Float64(4.0 * Float64(Float64(b * b) + Float64(Float64(a * a) * Float64(a + 1.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[(1.0 - N[(3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := N[(N[(N[(N[(2.0 * N[(N[(a * a), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] + N[Power[a, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.0 * N[(N[(b * b), $MachinePrecision] + N[(N[(a * a), $MachinePrecision] * N[(a + 1.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(1 - 3 \cdot a\right)\right)\right) - 1
\left(\left(\mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {b}^{4}\right) + {a}^{4}\right) + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) + -1

Error?

Derivation?

  1. Initial program 0.28

    \[\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(1 - 3 \cdot a\right)\right)\right) - 1 \]
  2. Taylor expanded in a around 0 0.03

    \[\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(1 - 3 \cdot a\right)\right)\right) - 1 \]
  3. Simplified0.03

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

    [Start]0.03

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

    +-commutative [=>]0.03

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

    associate-+r+ [=>]0.03

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

    fma-def [=>]0.03

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

    unpow2 [=>]0.03

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

    unpow2 [=>]0.03

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

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

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

    [Start]0.08

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

    unpow2 [=>]0.08

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

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

Alternatives

Alternative 1
Error0.33%
Cost7936
\[\left(4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + -1 \]
Alternative 2
Error0.3%
Cost7689
\[\begin{array}{l} \mathbf{if}\;b \leq -1.35 \cdot 10^{-8} \lor \neg \left(b \leq 2 \cdot 10^{-7}\right):\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(b \cdot b\right) \cdot 4\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) + -1\\ \end{array} \]
Alternative 3
Error3.6%
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -4.6 \lor \neg \left(a \leq 8.8 \cdot 10^{-48}\right):\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot -12 + \left(b \cdot b + 4\right)\right) + -1\\ \end{array} \]
Alternative 4
Error3.5%
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -4.6 \lor \neg \left(a \leq 8.8 \cdot 10^{-48}\right):\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right) + -1\\ \end{array} \]
Alternative 5
Error3.68%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \leq -4.6 \lor \neg \left(a \leq 8.8 \cdot 10^{-48}\right):\\ \;\;\;\;a \cdot \left(a \cdot \left(4 + a \cdot \left(a + 4\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(a \cdot -12 + \left(b \cdot b + 4\right)\right) + -1\\ \end{array} \]
Alternative 6
Error4.89%
Cost1097
\[\begin{array}{l} \mathbf{if}\;a \leq -4.6 \lor \neg \left(a \leq 8.8 \cdot 10^{-48}\right):\\ \;\;\;\;a \cdot \left(a \cdot \left(4 + a \cdot \left(a + 4\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b + 1\right) \cdot \left(b \cdot b + -1\right)\\ \end{array} \]
Alternative 7
Error5.49%
Cost969
\[\begin{array}{l} \mathbf{if}\;a \leq -140000 \lor \neg \left(a \leq 1.9\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b + 1\right) \cdot \left(b \cdot b + -1\right)\\ \end{array} \]
Alternative 8
Error6.05%
Cost969
\[\begin{array}{l} \mathbf{if}\;a \leq -45000 \lor \neg \left(a \leq 8.8 \cdot 10^{-48}\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot \left(a + 4\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot b + 1\right) \cdot \left(b \cdot b + -1\right)\\ \end{array} \]
Alternative 9
Error20.13%
Cost576
\[\left(a \cdot a\right) \cdot \left(a \cdot a\right) + -1 \]
Alternative 10
Error35.24%
Cost448
\[a \cdot \left(a \cdot 4\right) + -1 \]
Alternative 11
Error36.58%
Cost64
\[-1 \]

Error

Reproduce?

herbie shell --seed 2023102 
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (25)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (+ (* (* a a) (+ 1.0 a)) (* (* b b) (- 1.0 (* 3.0 a)))))) 1.0))