Average Error: 0.2 → 0.2
Time: 23.7s
Precision: binary64
Cost: 46656
\[\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(\sqrt[3]{a}, \sqrt[3]{a \cdot a} \cdot \left(4 \cdot a\right), 4 \cdot \left({a}^{3} + \left(b \cdot b\right) \cdot \mathsf{fma}\left(a, -3, 1\right)\right) + {\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2}\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
   (cbrt a)
   (* (cbrt (* a a)) (* 4.0 a))
   (+
    (* 4.0 (+ (pow a 3.0) (* (* b b) (fma a -3.0 1.0))))
    (pow (fma b b (* a a)) 2.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(cbrt(a), (cbrt((a * a)) * (4.0 * a)), ((4.0 * (pow(a, 3.0) + ((b * b) * fma(a, -3.0, 1.0)))) + pow(fma(b, b, (a * a)), 2.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(cbrt(a), Float64(cbrt(Float64(a * a)) * Float64(4.0 * a)), Float64(Float64(4.0 * Float64((a ^ 3.0) + Float64(Float64(b * b) * fma(a, -3.0, 1.0)))) + (fma(b, b, Float64(a * a)) ^ 2.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[(N[Power[a, 1/3], $MachinePrecision] * N[(N[Power[N[(a * a), $MachinePrecision], 1/3], $MachinePrecision] * N[(4.0 * a), $MachinePrecision]), $MachinePrecision] + N[(N[(4.0 * N[(N[Power[a, 3.0], $MachinePrecision] + N[(N[(b * b), $MachinePrecision] * N[(a * -3.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(b * b + N[(a * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $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(\sqrt[3]{a}, \sqrt[3]{a \cdot a} \cdot \left(4 \cdot a\right), 4 \cdot \left({a}^{3} + \left(b \cdot b\right) \cdot \mathsf{fma}\left(a, -3, 1\right)\right) + {\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2}\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. Applied egg-rr0.2

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(a, 4 \cdot a, \mathsf{fma}\left(4, {a}^{3}, \mathsf{fma}\left(\left(4 \cdot b\right) \cdot b, \mathsf{fma}\left(a, -3, 1\right), {\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2}\right)\right)\right)} - 1 \]
    Proof
  4. Applied egg-rr0.2

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

Alternatives

Alternative 1
Error0.2
Cost46272
\[\mathsf{fma}\left(a, 4 \cdot a, \mathsf{fma}\left(4, {a}^{3}, \mathsf{fma}\left(\left(4 \cdot b\right) \cdot b, \mathsf{fma}\left(a, -3, 1\right), {\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2}\right)\right)\right) - 1 \]
Alternative 2
Error0.2
Cost8320
\[\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 \]
Alternative 3
Error1.3
Cost8200
\[\begin{array}{l} t_0 := \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\\ \mathbf{if}\;b \leq -0.00125:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(a \cdot a + t_0\right)\right) - 1\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-17}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + t_0\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a\right)\right) - 1\\ \end{array} \]
Alternative 4
Error1.3
Cost8200
\[\begin{array}{l} t_0 := 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)\\ \mathbf{if}\;b \leq -0.00165:\\ \;\;\;\;\left({b}^{4} + t_0\right) - 1\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{-17}:\\ \;\;\;\;\left({a}^{4} + t_0\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a\right)\right) - 1\\ \end{array} \]
Alternative 5
Error0.2
Cost7936
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(1 + a\right) + b \cdot b\right)\right) - 1 \]
Alternative 6
Error1.4
Cost7812
\[\begin{array}{l} \mathbf{if}\;b \leq -2.2 \cdot 10^{-8}:\\ \;\;\;\;\left({b}^{4} + 4 \cdot \left(a \cdot a + \left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right)\right)\right) - 1\\ \mathbf{elif}\;b \leq 1.5 \cdot 10^{-17}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a\right)\right) - 1\\ \end{array} \]
Alternative 7
Error1.4
Cost7688
\[\begin{array}{l} \mathbf{if}\;b \leq -2.2 \cdot 10^{-8}:\\ \;\;\;\;\left({b}^{4} + \left(4 \cdot b\right) \cdot b\right) - 1\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-17}:\\ \;\;\;\;\left({a}^{4} + 4 \cdot \left(\left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(a \cdot a\right)\right) - 1\\ \end{array} \]
Alternative 8
Error1.8
Cost7560
\[\begin{array}{l} t_0 := \left({a}^{4} + 4 \cdot \left(\left(1 + a\right) \cdot \left(a \cdot a\right)\right)\right) - 1\\ \mathbf{if}\;a \leq -9.8 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 2.05 \cdot 10^{-15}:\\ \;\;\;\;\left({b}^{4} + \left(4 \cdot b\right) \cdot b\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error1.9
Cost7304
\[\begin{array}{l} t_0 := \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + 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\\ \mathbf{if}\;a \leq -1.05 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 2.05 \cdot 10^{-15}:\\ \;\;\;\;\left({b}^{4} + \left(4 \cdot b\right) \cdot b\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 10
Error2.0
Cost2120
\[\begin{array}{l} t_0 := \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right) + 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\\ \mathbf{if}\;a \leq -2.9 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 2 \cdot 10^{-15}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error11.3
Cost1352
\[\begin{array}{l} t_0 := \left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) - 1\\ \mathbf{if}\;b \leq -0.000142:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.000145:\\ \;\;\;\;\left(\left(b \cdot b\right) \cdot \left(4 + -12 \cdot a\right) + 4 \cdot \left(a \cdot a\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 12
Error12.1
Cost704
\[\left(b \cdot b\right) \cdot \left(b \cdot b + 4\right) - 1 \]
Alternative 13
Error22.8
Cost448
\[\left(4 \cdot b\right) \cdot b - 1 \]
Alternative 14
Error23.8
Cost64
\[-1 \]

Error

Reproduce

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