Average Error: 0.2 → 0.0
Time: 9.3s
Precision: binary64
Cost: 27008
\[\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({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right) + 4 \cdot \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right)\right) + {a}^{3} \cdot -4 \]
(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 (hypot a b) 4.0) -1.0) (* 4.0 (fma (* b b) (+ a 3.0) (* a a))))
  (* (pow a 3.0) -4.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(hypot(a, b), 4.0) + -1.0) + (4.0 * fma((b * b), (a + 3.0), (a * a)))) + (pow(a, 3.0) * -4.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((hypot(a, b) ^ 4.0) + -1.0) + Float64(4.0 * fma(Float64(b * b), Float64(a + 3.0), Float64(a * a)))) + Float64((a ^ 3.0) * -4.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[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + -1.0), $MachinePrecision] + N[(4.0 * N[(N[(b * b), $MachinePrecision] * N[(a + 3.0), $MachinePrecision] + N[(a * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[a, 3.0], $MachinePrecision] * -4.0), $MachinePrecision]), $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({\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + -1\right) + 4 \cdot \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right)\right) + {a}^{3} \cdot -4

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. Simplified0.0

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

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

    associate--l+ [=>]0.2

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

    +-commutative [=>]0.2

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

    associate-+l- [=>]0.2

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

    fma-neg [=>]0.2

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

    +-commutative [=>]0.2

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

    distribute-rgt-out-- [<=]0.2

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

    *-lft-identity [=>]0.2

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

    associate-+r- [=>]0.2

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

    fma-def [=>]0.2

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

    +-commutative [=>]0.2

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

    cube-unmult [=>]0.2

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

    neg-sub0 [=>]0.2

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

    associate--r- [=>]0.2

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

    metadata-eval [=>]0.2

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

    metadata-eval [<=]0.2

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

    +-commutative [<=]0.2

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

    unpow2 [=>]0.2

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

    unpow1 [<=]0.2

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

    sqr-pow [=>]0.2

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

    associate-*l* [=>]0.1

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

    *-commutative [=>]0.1

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

    unpow1 [<=]0.1

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

    sqr-pow [=>]0.1

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

    cube-unmult [=>]0.1

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

    pow-plus [=>]0.0

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

    metadata-eval [=>]0.0

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

    unpow1/2 [=>]0.0

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

    hypot-def [=>]0.0

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

    metadata-eval [=>]0.0

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

    metadata-eval [=>]0.0

    \[ \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot b, a + 3, a \cdot a\right) - {a}^{3}, {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \color{blue}{-1}\right) \]
  3. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.2
Cost8196
\[\begin{array}{l} t_0 := {\left(b \cdot b + a \cdot a\right)}^{2}\\ \mathbf{if}\;a \leq -5 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(t_0 + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + a \cdot \left(b \cdot b\right)\right)\right)\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-9}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(t_0 + \left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)\right)\\ \end{array} \]
Alternative 2
Error0.2
Cost8192
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 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) \]
Alternative 3
Error0.2
Cost8068
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 3 \cdot 10^{-12}:\\ \;\;\;\;-1 + \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) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(b \cdot b\right) \cdot 12\right)\\ \end{array} \]
Alternative 4
Error0.2
Cost7689
\[\begin{array}{l} \mathbf{if}\;b \leq -3.4 \cdot 10^{-9} \lor \neg \left(b \leq 1.62 \cdot 10^{-6}\right):\\ \;\;\;\;-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(b \cdot b\right) \cdot 12\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right) + {a}^{4}\right)\\ \end{array} \]
Alternative 5
Error1.2
Cost7680
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + \left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)\right) \]
Alternative 6
Error1.8
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -2.7 \cdot 10^{-6} \lor \neg \left(a \leq 0.0003\right):\\ \;\;\;\;-1 + \left(a \cdot \left(a \cdot 4\right) + {a}^{3} \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \end{array} \]
Alternative 7
Error1.7
Cost7561
\[\begin{array}{l} \mathbf{if}\;a \leq -1.2 \cdot 10^{-5} \lor \neg \left(a \leq 2.8 \cdot 10^{-6}\right):\\ \;\;\;\;-1 + \left(\left(1 - a\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \end{array} \]
Alternative 8
Error1.8
Cost7305
\[\begin{array}{l} \mathbf{if}\;a \leq -1 \cdot 10^{-5} \lor \neg \left(a \leq 4.6 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \end{array} \]
Alternative 9
Error1.9
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \leq -4 \cdot 10^{-5} \lor \neg \left(a \leq 1.22 \cdot 10^{-5}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 10
Error1.9
Cost1097
\[\begin{array}{l} \mathbf{if}\;a \leq -2.15 \cdot 10^{-5} \lor \neg \left(a \leq 1.1 \cdot 10^{-6}\right):\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right)\\ \end{array} \]
Alternative 11
Error11.9
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + 12\right) \]
Alternative 12
Error22.7
Cost448
\[-1 + \left(b \cdot b\right) \cdot 12 \]
Alternative 13
Error23.7
Cost64
\[-1 \]

Error

Reproduce

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