Average Error: 0.2 → 0.0
Time: 8.4s
Precision: binary64
Cost: 26816
\[\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(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\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) (+ 3.0 a)))))
  1.0))
(FPCore (a b)
 :precision binary64
 (+
  (pow (hypot a b) 4.0)
  (fma 4.0 (fma a (- a (* a a)) (* b (* b (+ a 3.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) * (3.0 + a))))) - 1.0;
}
double code(double a, double b) {
	return pow(hypot(a, b), 4.0) + fma(4.0, fma(a, (a - (a * a)), (b * (b * (a + 3.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(3.0 + a))))) - 1.0)
end
function code(a, b)
	return Float64((hypot(a, b) ^ 4.0) + fma(4.0, fma(a, Float64(a - Float64(a * a)), Float64(b * Float64(b * Float64(a + 3.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[(3.0 + a), $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 - N[(a * a), $MachinePrecision]), $MachinePrecision] + N[(b * N[(b * N[(a + 3.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(3 + a\right)\right)\right) - 1
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(4, \mathsf{fma}\left(a, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\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(3 + 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, a - a \cdot a, b \cdot \left(b \cdot \left(a + 3\right)\right)\right), -1\right)} \]
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.2
Cost21056
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left({\left(\sqrt[3]{a \cdot \left(a \cdot \left(1 - a\right)\right)}\right)}^{3} + \left(a + 3\right) \cdot \left(b \cdot b\right)\right)\right) \]
Alternative 2
Error0.2
Cost8192
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a + 3\right) \cdot \left(b \cdot b\right) + \left(a \cdot a\right) \cdot \left(1 - a\right)\right)\right) \]
Alternative 3
Error1.3
Cost7680
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + \left(\left(a \cdot a\right) \cdot -4\right) \cdot \left(a + -1\right)\right) \]
Alternative 4
Error1.8
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-32}:\\ \;\;\;\;-1 + \left(\left(\left(a \cdot a\right) \cdot -4\right) \cdot \left(a + -1\right) + {a}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + b \cdot \left(b \cdot 12\right)\right)\\ \end{array} \]
Alternative 5
Error1.5
Cost7424
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + b \cdot \left(b \cdot 12\right)\right) \]
Alternative 6
Error1.8
Cost7300
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-32}:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + b \cdot \left(b \cdot 12\right)\right)\\ \end{array} \]
Alternative 7
Error2.5
Cost6920
\[\begin{array}{l} t_0 := -1 + {b}^{4}\\ \mathbf{if}\;b \leq -0.0008553300988632887:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 384.862728628727:\\ \;\;\;\;-1 + a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error12.1
Cost832
\[-1 + a \cdot \left(a \cdot \left(4 + a \cdot \left(a + -4\right)\right)\right) \]
Alternative 9
Error12.9
Cost704
\[-1 + a \cdot \left(a \cdot \left(a \cdot \left(a + -4\right)\right)\right) \]
Alternative 10
Error13.4
Cost576
\[-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right) \]
Alternative 11
Error13.4
Cost576
\[-1 + a \cdot \left(a \cdot \left(a \cdot a\right)\right) \]
Alternative 12
Error22.8
Cost448
\[-1 + b \cdot \left(b \cdot 12\right) \]
Alternative 13
Error23.9
Cost64
\[-1 \]

Error

Reproduce

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