Average Error: 0.2 → 0.0
Time: 5.7s
Precision: binary64
Cost: 19776
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
\[{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right) \]
(FPCore (a b)
 :precision binary64
 (- (+ (pow (+ (* a a) (* b b)) 2.0) (* 4.0 (* b b))) 1.0))
(FPCore (a b)
 :precision binary64
 (+ (pow (hypot a b) 4.0) (fma b (* b 4.0) -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) {
	return pow(hypot(a, b), 4.0) + fma(b, (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(b * b))) - 1.0)
end
function code(a, b)
	return Float64((hypot(a, b) ^ 4.0) + fma(b, Float64(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[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
code[a_, b_] := N[(N[Power[N[Sqrt[a ^ 2 + b ^ 2], $MachinePrecision], 4.0], $MachinePrecision] + N[(b * N[(b * 4.0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
{\left(\mathsf{hypot}\left(a, b\right)\right)}^{4} + \mathsf{fma}\left(b, b \cdot 4, -1\right)

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. Simplified0.0

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

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

Alternatives

Alternative 1
Error0.1
Cost13952
\[-1 + \mathsf{fma}\left(b, b \cdot \left(4 + \left(2 \cdot \left(a \cdot a\right) + b \cdot b\right)\right), {a}^{4}\right) \]
Alternative 2
Error0.2
Cost13696
\[-1 + \left({\left(\mathsf{fma}\left(b, b, a \cdot a\right)\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) \]
Alternative 3
Error0.2
Cost7424
\[-1 + \left(4 \cdot \left(b \cdot b\right) + {\left(a \cdot a + b \cdot b\right)}^{2}\right) \]
Alternative 4
Error1.6
Cost7304
\[\begin{array}{l} \mathbf{if}\;a \leq -0.0014943704821242822:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;a \leq 2.1914065122771964 \cdot 10^{-7}:\\ \;\;\;\;-1 + \left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]
Alternative 5
Error1.4
Cost7304
\[\begin{array}{l} t_0 := 4 \cdot \left(b \cdot b\right)\\ \mathbf{if}\;b \leq -0.08140582780265153:\\ \;\;\;\;-1 + \left(t_0 + {b}^{4}\right)\\ \mathbf{elif}\;b \leq 3.969294319403511 \cdot 10^{-5}:\\ \;\;\;\;-1 + \left({a}^{4} + t_0\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \left(4 + \left(2 \cdot \left(a \cdot a\right) + b \cdot b\right)\right)\right)\\ \end{array} \]
Alternative 6
Error1.6
Cost6920
\[\begin{array}{l} \mathbf{if}\;a \leq -0.0014943704821242822:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;a \leq 0.6361844996922318:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \left(4 + \left(2 \cdot \left(a \cdot a\right) + b \cdot b\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]
Alternative 7
Error1.7
Cost1352
\[\begin{array}{l} t_0 := -1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\\ \mathbf{if}\;a \leq -0.0014943704821242822:\\ \;\;\;\;t_0\\ \mathbf{elif}\;a \leq 2.1914065122771964 \cdot 10^{-7}:\\ \;\;\;\;-1 + b \cdot \left(b \cdot \left(4 + \left(2 \cdot \left(a \cdot a\right) + b \cdot b\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error1.7
Cost1220
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 4.802262502050906 \cdot 10^{-14}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a + 2 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 9
Error1.8
Cost964
\[\begin{array}{l} \mathbf{if}\;a \cdot a \leq 4.802262502050906 \cdot 10^{-14}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \end{array} \]
Alternative 10
Error2.2
Cost840
\[\begin{array}{l} t_0 := -1 + b \cdot \left(b \cdot \left(b \cdot b\right)\right)\\ \mathbf{if}\;b \leq -0.08140582780265153:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b \leq 0.19683892250366494:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 11
Error12.0
Cost576
\[-1 + b \cdot \left(b \cdot \left(b \cdot b\right)\right) \]
Alternative 12
Error22.0
Cost448
\[-1 + b \cdot \left(b \cdot 4\right) \]
Alternative 13
Error23.0
Cost64
\[-1 \]

Error

Reproduce

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