?

Average Accuracy: 99.7% → 100.0%
Time: 8.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 \]
\[{\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 99.7%

    \[\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. Simplified100.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]99.7

    \[ \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+ [=>]99.7

    \[ \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 simplification100.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
Accuracy99.6%
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 2
Accuracy95.9%
Cost7560
\[\begin{array}{l} \mathbf{if}\;b \leq -1.55 \cdot 10^{-6}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{-38}:\\ \;\;\;\;-1 + \left({a}^{4} + 4 \cdot \left(\left(a \cdot a\right) \cdot \left(a + 1\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]
Alternative 3
Accuracy95.8%
Cost7172
\[\begin{array}{l} \mathbf{if}\;b \leq -5.5 \cdot 10^{-7}:\\ \;\;\;\;-1 + \left({b}^{4} + 4 \cdot \left(b \cdot b\right)\right)\\ \mathbf{elif}\;b \leq 1.8 \cdot 10^{-38}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {b}^{4}\\ \end{array} \]
Alternative 4
Accuracy95.3%
Cost6921
\[\begin{array}{l} \mathbf{if}\;b \leq -0.056 \lor \neg \left(b \leq 5 \cdot 10^{-42}\right):\\ \;\;\;\;-1 + {b}^{4}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \end{array} \]
Alternative 5
Accuracy96.4%
Cost6792
\[\begin{array}{l} \mathbf{if}\;b \leq -85:\\ \;\;\;\;{b}^{4}\\ \mathbf{elif}\;b \leq 1.9:\\ \;\;\;\;-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{b}^{4}\\ \end{array} \]
Alternative 6
Accuracy81.0%
Cost832
\[-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot \left(a + 4\right)\right) \]
Alternative 7
Accuracy79.0%
Cost704
\[-1 + \left(a \cdot a\right) \cdot \left(4 + a \cdot a\right) \]
Alternative 8
Accuracy79.5%
Cost704
\[-1 + \left(a \cdot a\right) \cdot \left(a \cdot \left(a + 4\right)\right) \]
Alternative 9
Accuracy78.8%
Cost576
\[-1 + \left(a \cdot a\right) \cdot \left(a \cdot a\right) \]
Alternative 10
Accuracy64.3%
Cost448
\[-1 + a \cdot \left(a \cdot 4\right) \]
Alternative 11
Accuracy63.0%
Cost64
\[-1 \]

Error

Reproduce?

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