Average Error: 0.2 → 0.2
Time: 13.1s
Precision: binary64
Cost: 20288
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[\begin{array}{l} t_0 := \mathsf{fma}\left(a, a, b \cdot b\right)\\ \mathsf{fma}\left(t_0, t_0, 4 \cdot \left(b \cdot b\right)\right) - 1 \end{array} \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b)
 :precision binary64
 (let* ((t_0 (fma a a (* b b)))) (- (fma t_0 t_0 (* 4.0 (* b b))) 1.0)))
double code(double a, double b) {
	return (pow(((a * a) + (b * b)), 2.0) + (4.0 * (b * b))) - 1.0;
}
double code(double a, double b) {
	double t_0 = fma(a, a, (b * b));
	return fma(t_0, t_0, (4.0 * (b * b))) - 1.0;
}
function code(a, b)
	return Float64(Float64((Float64(Float64(a * a) + Float64(b * b)) ^ 2.0) + Float64(4.0 * Float64(b * b))) - 1.0)
end
function code(a, b)
	t_0 = fma(a, a, Float64(b * b))
	return Float64(fma(t_0, t_0, Float64(4.0 * Float64(b * b))) - 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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := Block[{t$95$0 = N[(a * a + N[(b * b), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 * t$95$0 + N[(4.0 * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\begin{array}{l}
t_0 := \mathsf{fma}\left(a, a, b \cdot b\right)\\
\mathsf{fma}\left(t_0, t_0, 4 \cdot \left(b \cdot b\right)\right) - 1
\end{array}

Error

Derivation

  1. Initial program 0.2

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Applied egg-rr0.2

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

Alternatives

Alternative 1
Error0.2
Cost19968
\[{\left(\mathsf{fma}\left(a, a, b \cdot b\right)\right)}^{2} + \mathsf{fma}\left(4 \cdot b, b, -1\right) \]
Alternative 2
Error1.7
Cost7688
\[\begin{array}{l} t_0 := \left({a}^{4} + \left(4 + 2 \cdot \left(a \cdot a\right)\right) \cdot \left(b \cdot b\right)\right) - 1\\ \mathbf{if}\;a \leq -0.205:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-26}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 4\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error0.2
Cost7424
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
Alternative 4
Error1.8
Cost7304
\[\begin{array}{l} t_0 := {a}^{4} + -1\\ \mathbf{if}\;a \leq -0.205:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-26}:\\ \;\;\;\;\left({b}^{4} + \left(b \cdot b\right) \cdot 4\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.8
Cost7240
\[\begin{array}{l} t_0 := {a}^{4} + -1\\ \mathbf{if}\;a \leq -0.205:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-26}:\\ \;\;\;\;b \cdot \left(b \cdot \mathsf{fma}\left(b, b, 4\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error1.8
Cost6920
\[\begin{array}{l} t_0 := {a}^{4} + -1\\ \mathbf{if}\;a \leq -0.205:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-26}:\\ \;\;\;\;\left(b \cdot b\right) \cdot \left(b \cdot b + \left(4 + 2 \cdot \left(a \cdot a\right)\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error11.7
Cost1088
\[\left(b \cdot b\right) \cdot \left(b \cdot b + \left(4 + 2 \cdot \left(a \cdot a\right)\right)\right) - 1 \]
Alternative 8
Error22.3
Cost832
\[\left(4 + \left(a + a\right) \cdot a\right) \cdot \left(b \cdot b\right) - 1 \]
Alternative 9
Error22.4
Cost448
\[\left(4 \cdot b\right) \cdot b - 1 \]
Alternative 10
Error23.4
Cost64
\[-1 \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (26)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))