Average Error: 0.2 → 0.0
Time: 8.0s
Precision: binary64
Cost: 20544
\[\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, \left(a + 3\right) \cdot \left(b \cdot b\right) + a \cdot \left(a - a \cdot a\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 (+ (* (+ a 3.0) (* b b)) (* a (- a (* a a)))) -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, (((a + 3.0) * (b * b)) + (a * (a - (a * a)))), -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, Float64(Float64(Float64(a + 3.0) * Float64(b * b)) + Float64(a * Float64(a - Float64(a * a)))), -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[(N[(N[(a + 3.0), $MachinePrecision] * N[(b * b), $MachinePrecision]), $MachinePrecision] + N[(a * N[(a - N[(a * a), $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, \left(a + 3\right) \cdot \left(b \cdot b\right) + a \cdot \left(a - a \cdot a\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. Applied egg-rr0.0

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

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

Alternatives

Alternative 1
Error0.2
Cost8192
\[-1 + \left({\left(b \cdot b + a \cdot a\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 2
Error1.0
Cost8072
\[\begin{array}{l} t_0 := -1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(a \cdot a + b \cdot \left(b \cdot 3\right)\right)\right)\\ \mathbf{if}\;b \leq -41274473.30685318:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 1.613062509351647 \cdot 10^{-22}:\\ \;\;\;\;-1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.2
Cost8064
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 - a\right) + b \cdot \left(b \cdot 3\right)\right)\right) \]
Alternative 4
Error2.1
Cost7428
\[\begin{array}{l} \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;-1 + \left(a \cdot \left(a \cdot 4\right) + \left(a + -4\right) \cdot {a}^{3}\right)\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \end{array} \]
Alternative 5
Error2.1
Cost7304
\[\begin{array}{l} t_0 := -1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + b \cdot \left({b}^{3} + b \cdot 12\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error2.0
Cost7304
\[\begin{array}{l} t_0 := -1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left({b}^{4} + \left(b \cdot b\right) \cdot 12\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error2.1
Cost7240
\[\begin{array}{l} t_0 := -1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 12\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error2.1
Cost1864
\[\begin{array}{l} t_0 := -1 + \left(\left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) + \left(b \cdot b\right) \cdot \left(a \cdot \left(4 + a \cdot 2\right)\right)\right)\\ \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error2.2
Cost1224
\[\begin{array}{l} t_0 := -1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right)\\ \mathbf{if}\;a \leq -0.006932719870971392:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 1.6254641905450022 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(\left(b \cdot b\right) \cdot 12 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error12.2
Cost832
\[-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + -4\right)\right) \]
Alternative 11
Error13.5
Cost704
\[-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot a\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 2022241 
(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))