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

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}{\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), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{4}\right) + -1} \]
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error0.1
Cost33408
\[-1 + \mathsf{fma}\left(b \cdot b, \mathsf{fma}\left(b, b, \mathsf{fma}\left(a, a \cdot 2, 4\right)\right), {a}^{4} + a \cdot \left(4 \cdot \mathsf{fma}\left(a, a, a\right)\right)\right) \]
Alternative 2
Error2.6
Cost8068
\[\begin{array}{l} \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;-1 + \left({b}^{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)\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(b, b \cdot 2, 4\right) + a \cdot \left(4 + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4 + a \cdot \left(a + a\right)\right)\right)\\ \end{array} \]
Alternative 3
Error0.2
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 4
Error2.7
Cost7752
\[\begin{array}{l} \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(b, b \cdot 2, 4\right) + a \cdot \left(4 + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4 + a \cdot \left(a + a\right)\right)\right)\\ \end{array} \]
Alternative 5
Error2.6
Cost7752
\[\begin{array}{l} \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \left(4 + a \cdot \left(a \cdot 2 + -12\right)\right) + {b}^{3}\right)\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(\mathsf{fma}\left(b, b \cdot 2, 4\right) + a \cdot \left(4 + a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4 + a \cdot \left(a + a\right)\right)\right)\\ \end{array} \]
Alternative 6
Error3.4
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4 + a \cdot \left(a + a\right)\right)\right)\\ \end{array} \]
Alternative 7
Error3.4
Cost7240
\[\begin{array}{l} \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right)\\ \end{array} \]
Alternative 8
Error3.5
Cost7176
\[\begin{array}{l} t_0 := -1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + {a}^{3} \cdot \left(4 + a\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error3.9
Cost6920
\[\begin{array}{l} t_0 := -1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{if}\;b \leq -1213061.3420896376:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 1.0423447834410695 \cdot 10^{-33}:\\ \;\;\;\;-1 + {a}^{4}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error11.8
Cost704
\[-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right) \]
Alternative 11
Error12.9
Cost576
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right) \]
Alternative 12
Error12.9
Cost576
\[-1 + b \cdot \left(b \cdot \left(b \cdot b\right)\right) \]
Alternative 13
Error22.9
Cost448
\[-1 + 4 \cdot \left(b \cdot b\right) \]

Error

Reproduce

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