?

Average Error: 0.2 → 0.0
Time: 10.6s
Precision: binary64
Cost: 27584

?

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

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

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

    [Start]0.0

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

    associate-+r+ [=>]0.0

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

    unpow2 [=>]0.0

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

    fma-def [=>]0.0

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

    cancel-sign-sub-inv [=>]0.0

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

    metadata-eval [=>]0.0

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

    *-commutative [<=]0.0

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

    fma-def [=>]0.0

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

    unpow2 [=>]0.0

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

    associate-*r* [=>]0.0

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

    unpow2 [=>]0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost21440
\[\left(\left({a}^{4} + \mathsf{fma}\left(2, \left(a \cdot a\right) \cdot \left(b \cdot b\right), {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 + a \cdot -3\right)\right)\right) + -1 \]
Alternative 2
Error0.1
Cost20928
\[\left({b}^{4} + \left({a}^{4} + \mathsf{fma}\left(4 + 2 \cdot \left(a \cdot a\right), b \cdot b, 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right)\right)\right)\right)\right) + -1 \]
Alternative 3
Error0.2
Cost8320
\[\left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) + -1 \]
Alternative 4
Error0.2
Cost7936
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(1 + a\right)\right)\right) + -1 \]
Alternative 5
Error0.3
Cost7684
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-82}:\\ \;\;\;\;\left({a}^{4} + \left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 6
Error1.7
Cost7561
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016 \lor \neg \left(b \leq 0.145\right):\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({a}^{4} + \left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right)\right) + -1\\ \end{array} \]
Alternative 7
Error1.8
Cost7560
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016:\\ \;\;\;\;\left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right) + -1\\ \mathbf{elif}\;b \leq 0.145:\\ \;\;\;\;\left({a}^{4} + \left(4 \cdot \left(a \cdot a\right)\right) \cdot \left(1 + a\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 8
Error2.6
Cost7304
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016:\\ \;\;\;\;\left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right) + -1\\ \mathbf{elif}\;b \leq 0.145:\\ \;\;\;\;{a}^{3} \cdot \left(4 + a\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right) + -1\\ \end{array} \]
Alternative 9
Error2.7
Cost7177
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016 \lor \neg \left(b \leq 0.145\right):\\ \;\;\;\;\left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{a}^{3} \cdot \left(4 + a\right) + -1\\ \end{array} \]
Alternative 10
Error3.4
Cost1481
\[\begin{array}{l} \mathbf{if}\;b \leq -0.017 \lor \neg \left(b \leq 8 \cdot 10^{-38}\right):\\ \;\;\;\;\left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1\\ \end{array} \]
Alternative 11
Error3.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016 \lor \neg \left(b \leq 8 \cdot 10^{-38}\right):\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + \left(b \cdot b + a \cdot -12\right)\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1\\ \end{array} \]
Alternative 12
Error3.4
Cost969
\[\begin{array}{l} \mathbf{if}\;b \leq -0.016 \lor \neg \left(b \leq 8 \cdot 10^{-38}\right):\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) + -1\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1\\ \end{array} \]
Alternative 13
Error12.6
Cost704
\[\left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) + -1 \]
Alternative 14
Error12.7
Cost576
\[\left(a \cdot a\right) \cdot \left(a \cdot a\right) + -1 \]
Alternative 15
Error22.5
Cost448
\[4 \cdot \left(a \cdot a\right) + -1 \]
Alternative 16
Error23.3
Cost64
\[-1 \]

Error

Reproduce?

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