?

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

    [Start]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 \]

    associate--l+ [=>]0.2

    \[ \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(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) - 1\right)} \]
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error1.7
Cost8200
\[\begin{array}{l} \mathbf{if}\;b \leq -3.5 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(2 \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right) + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 10^{-20}:\\ \;\;\;\;-1 + \left({a}^{4} + \left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-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)\\ \end{array} \]
Alternative 2
Error0.2
Cost7936
\[-1 + \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b + \left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right) \]
Alternative 3
Error1.5
Cost7560
\[\begin{array}{l} \mathbf{if}\;b \leq -2.8 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(2 \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right) + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 10^{-7}:\\ \;\;\;\;-1 + \left({a}^{4} + \left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 4
Error1.5
Cost7304
\[\begin{array}{l} \mathbf{if}\;b \leq -5.3 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(2 \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right) + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{-9}:\\ \;\;\;\;-1 + \left(\left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \end{array} \]
Alternative 5
Error3.3
Cost1481
\[\begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+18} \lor \neg \left(a \leq 1.05\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right)\\ \end{array} \]
Alternative 6
Error1.6
Cost1480
\[\begin{array}{l} t_0 := 4 + b \cdot b\\ \mathbf{if}\;b \leq -5.5 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(2 \cdot \left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right) + \left(b \cdot b\right) \cdot t_0\right)\\ \mathbf{elif}\;b \leq 5.7 \cdot 10^{-8}:\\ \;\;\;\;-1 + \left(\left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot t_0\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right)\\ \end{array} \]
Alternative 7
Error1.8
Cost1476
\[\begin{array}{l} \mathbf{if}\;b \cdot b \leq 5 \cdot 10^{-23}:\\ \;\;\;\;-1 + \left(\left(a + 1\right) \cdot \left(4 \cdot \left(a \cdot a\right)\right) + \left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot \left(b \cdot \left(4 + b \cdot b\right)\right) + b \cdot \left(b \cdot \left(a \cdot -12\right)\right)\right)\\ \end{array} \]
Alternative 8
Error3.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+18} \lor \neg \left(a \leq 0.42\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + \left(b \cdot b + a \cdot -12\right)\right)\\ \end{array} \]
Alternative 9
Error3.4
Cost969
\[\begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+18} \lor \neg \left(a \leq 0.85\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \end{array} \]
Alternative 10
Error4.4
Cost841
\[\begin{array}{l} \mathbf{if}\;a \leq -8.2 \cdot 10^{+18} \lor \neg \left(a \leq 1.2\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \end{array} \]
Alternative 11
Error12.5
Cost713
\[\begin{array}{l} \mathbf{if}\;a \leq -2.4 \lor \neg \left(a \leq 0.41\right):\\ \;\;\;\;\left(a \cdot a\right) \cdot \left(a \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + 4 \cdot \left(b \cdot b\right)\\ \end{array} \]
Alternative 12
Error51.9
Cost448
\[\left(a \cdot a\right) \cdot \left(a \cdot a\right) \]

Error

Reproduce?

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