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

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

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

    unpow2 [=>]0.2

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

    unpow1 [<=]0.2

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

    sqr-pow [=>]0.2

    \[ \left(a \cdot a + b \cdot b\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)} + \left(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) - 1\right) \]

    associate-*r* [=>]0.1

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

    *-commutative [=>]0.1

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

    unpow1 [<=]0.1

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

    sqr-pow [=>]0.1

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

    cube-unmult [=>]0.1

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

    pow-plus [=>]0.0

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

    metadata-eval [=>]0.0

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

    unpow1/2 [=>]0.0

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

    hypot-def [=>]0.0

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

    metadata-eval [=>]0.0

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

    fma-neg [=>]0.0

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

    associate-*l* [=>]0.0

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

    fma-def [=>]0.0

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

    +-commutative [=>]0.0

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

    distribute-rgt-in [=>]0.0

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

    *-lft-identity [=>]0.0

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

    fma-def [=>]0.0

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

    associate-*l* [=>]0.0

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

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

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

    +-commutative [=>]0.0

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

    *-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    metadata-eval [=>]0.0

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

    metadata-eval [=>]0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost14400
\[-1 + \left({\left(\mathsf{hypot}\left(b, a\right)\right)}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right)\right) \]
Alternative 2
Error0.2
Cost8704
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right) + \frac{1 - a \cdot a}{\frac{1 - a}{a \cdot a}}\right)\right) \]
Alternative 3
Error0.2
Cost8320
\[-1 + \left(4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + \left(b \cdot b\right) \cdot \left(1 + a \cdot -3\right)\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) \]
Alternative 4
Error1.1
Cost7944
\[\begin{array}{l} \mathbf{if}\;b \leq -6.8 \cdot 10^{-7}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 5 \cdot 10^{-59}:\\ \;\;\;\;-1 + \left(\left(a \cdot 4\right) \cdot \left(a + a \cdot a\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right)\\ \end{array} \]
Alternative 5
Error0.2
Cost7936
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right) + b \cdot b\right)\right) \]
Alternative 6
Error1.1
Cost7688
\[\begin{array}{l} \mathbf{if}\;b \leq -2.25 \cdot 10^{-7}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 6.8 \cdot 10^{-59}:\\ \;\;\;\;-1 + \left(\left(a \cdot 4\right) \cdot \left(a + a \cdot a\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + b \cdot \left(b \cdot 4\right)\right)\\ \end{array} \]
Alternative 7
Error1.9
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + \left({a}^{4} + \left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 8
Error1.9
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + \left(\left(a \cdot 4\right) \cdot \left(a + a \cdot a\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 9
Error1.9
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + \left(\left(a \cdot 4\right) \cdot \left(a + a \cdot a\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right)\\ \end{array} \]
Alternative 10
Error3.2
Cost7300
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + \left({a}^{4} + 4 \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]
Alternative 11
Error3.1
Cost7300
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + \left({a}^{4} + 4 \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 12
Error3.4
Cost6916
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]
Alternative 13
Error3.4
Cost964
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-34}:\\ \;\;\;\;\left(1 + a \cdot a\right) \cdot \left(-1 + a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]
Alternative 14
Error14.0
Cost704
\[\left(1 + a \cdot a\right) \cdot \left(-1 + a \cdot a\right) \]
Alternative 15
Error23.2
Cost448
\[-1 + 4 \cdot \left(a \cdot a\right) \]
Alternative 16
Error23.0
Cost448
\[-1 + 4 \cdot \left(b \cdot b\right) \]
Alternative 17
Error24.0
Cost64
\[-1 \]

Error

Reproduce

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