Average Error: 0.2 → 0.0
Time: 5.7s
Precision: binary64
Cost: 20544
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\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) + \left(b \cdot b\right) \cdot 4\right) + -1 \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b)
 :precision binary64
 (+
  (+ (+ (fma 2.0 (* (* a a) (* b b)) (pow b 4.0)) (pow a 4.0)) (* (* b b) 4.0))
  -1.0))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
double code(double a, double b) {
	return ((fma(2.0, ((a * a) * (b * b)), pow(b, 4.0)) + pow(a, 4.0)) + ((b * b) * 4.0)) + -1.0;
}
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 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(Float64(b * b) * 4.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[(b * b), $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[(N[(b * b), $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\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) + \left(b \cdot b\right) \cdot 4\right) + -1

Error

Derivation

  1. Initial program 0.2

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Taylor expanded in a around 0 0.0

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

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

    [Start]0.0

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

    +-commutative [<=]0.0

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

    associate-+r+ [=>]0.0

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

    fma-def [=>]0.0

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

    unpow2 [=>]0.0

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

    unpow2 [=>]0.0

    \[ \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(b \cdot b\right)\right) - 1 \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error0.0
Cost19776
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b \cdot b, 4, -1\right) \]
Alternative 2
Error0.1
Cost7936
\[-1 + \left(\left(b \cdot b\right) \cdot 4 + \left({a}^{4} + \left(b \cdot b\right) \cdot \left(b \cdot b + 2 \cdot \left(a \cdot a\right)\right)\right)\right) \]
Alternative 3
Error0.2
Cost7424
\[-1 + \left(\left(b \cdot b\right) \cdot 4 + {\left(a \cdot a + b \cdot b\right)}^{2}\right) \]
Alternative 4
Error2.1
Cost7305
\[\begin{array}{l} t_0 := \left(b \cdot b\right) \cdot 4\\ \mathbf{if}\;a \leq -62000000000 \lor \neg \left(a \leq 2.8\right):\\ \;\;\;\;-1 + \left({a}^{4} + t_0\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + t_0\right)\\ \end{array} \]
Alternative 5
Error10.9
Cost7040
\[-1 + \left({a}^{4} + \left(b \cdot b\right) \cdot 4\right) \]
Alternative 6
Error11.0
Cost960
\[-1 + \left(\left(b \cdot b\right) \cdot 4 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right) \]

Error

Reproduce

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