?

Average Error: 0.3% → 0.05%
Time: 11.8s
Precision: binary64
Cost: 45824

?

\[\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 \]
\[\mathsf{fma}\left(4, \mathsf{fma}\left(a, a, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(a, -3, 1\right), {a}^{3}\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\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
   4.0
   (fma a a (fma (* b b) (fma a -3.0 1.0) (pow a 3.0)))
   (pow (hypot a b) 4.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(4.0, fma(a, a, fma((b * b), fma(a, -3.0, 1.0), pow(a, 3.0))), pow(hypot(a, 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(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(fma(4.0, fma(a, a, fma(Float64(b * b), fma(a, -3.0, 1.0), (a ^ 3.0))), (hypot(a, 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[(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[(4.0 * N[(a * a + N[(N[(b * b), $MachinePrecision] * N[(a * -3.0 + 1.0), $MachinePrecision] + N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $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
\mathsf{fma}\left(4, \mathsf{fma}\left(a, a, \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(a, -3, 1\right), {a}^{3}\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right) + -1

Error?

Derivation?

  1. Initial program 0.3

    \[\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.05

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

    [Start]0.3

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

    sub-neg [=>]0.3

    \[ \color{blue}{\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) + \left(-1\right)} \]
  3. Final simplification0.05

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

Alternatives

Alternative 1
Error0.05%
Cost39488
\[{\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) \]
Alternative 2
Error0.1%
Cost20928
\[-1 + \left({a}^{4} + \left({b}^{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(a + 1\right)\right)\right)\right)\right) \]
Alternative 3
Error0.3%
Cost8320
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 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 4
Error0.36%
Cost8256
\[-1 + \left(\left(b \cdot b + a \cdot a\right) \cdot \mathsf{fma}\left(a, a, b \cdot b\right) + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) \]
Alternative 5
Error0.36%
Cost7936
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) \]
Alternative 6
Error2.69%
Cost7684
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-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} + \left(b \cdot b\right) \cdot \left(4 + 2 \cdot \left(a \cdot a\right)\right)\right)\\ \end{array} \]
Alternative 7
Error2.31%
Cost7680
\[\begin{array}{l} t_0 := b \cdot b + a \cdot a\\ -1 + \left({t_0}^{2} + 4 \cdot t_0\right) \end{array} \]
Alternative 8
Error4.23%
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right)\\ \end{array} \]
Alternative 9
Error2.84%
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-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} + \left(b \cdot b\right) \cdot \left(4 + a \cdot -12\right)\right)\\ \end{array} \]
Alternative 10
Error4.22%
Cost7300
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + b \cdot \left(4 \cdot b\right)\right)\\ \end{array} \]
Alternative 11
Error4.45%
Cost7176
\[\begin{array}{l} \mathbf{if}\;b \leq -6.2 \cdot 10^{-8}:\\ \;\;\;\;-1 + b \cdot \left(4 \cdot b + {b}^{3}\right)\\ \mathbf{elif}\;b \leq 7.8 \cdot 10^{-17}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \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)\\ \end{array} \]
Alternative 12
Error4.32%
Cost7172
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \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)\\ \end{array} \]
Alternative 13
Error5.04%
Cost6916
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 10^{-17}:\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \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)\\ \end{array} \]
Alternative 14
Error19.63%
Cost1216
\[-1 + \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) \]
Alternative 15
Error19.67%
Cost960
\[-1 + \left(b \cdot b\right) \cdot \left(4 + \left(b \cdot b + a \cdot -12\right)\right) \]
Alternative 16
Error19.69%
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) \]
Alternative 17
Error21.12%
Cost576
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right) \]
Alternative 18
Error37.12%
Cost448
\[-1 + 4 \cdot \left(b \cdot b\right) \]
Alternative 19
Error38.72%
Cost64
\[-1 \]

Error

Reproduce?

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