?

Average Accuracy: 99.7% → 100.0%
Time: 16.1s
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 \cdot b, 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(Float64(b * 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[(N[(b * b), $MachinePrecision] * 4.0 + -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 \cdot b, 4, -1\right)

Error?

Derivation?

  1. Initial program 99.7%

    \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1 \]
  2. Simplified100.0%

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

    [Start]99.7

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

    associate--l+ [=>]99.7

    \[ \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{2} + \left(4 \cdot \left(b \cdot b\right) - 1\right)} \]

    unpow2 [=>]99.7

    \[ \color{blue}{\left(a \cdot a + b \cdot b\right) \cdot \left(a \cdot a + b \cdot b\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]

    unpow1 [<=]99.7

    \[ \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{{\left(a \cdot a + b \cdot b\right)}^{1}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]

    sqr-pow [=>]99.7

    \[ \left(a \cdot a + b \cdot b\right) \cdot \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]

    associate-*r* [=>]99.8

    \[ \color{blue}{\left(\left(a \cdot a + b \cdot b\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}\right) \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)}} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]

    *-commutative [<=]99.8

    \[ \color{blue}{\left({\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} \cdot \left(a \cdot a + b \cdot b\right)\right)} \cdot {\left(a \cdot a + b \cdot b\right)}^{\left(\frac{1}{2}\right)} + \left(4 \cdot \left(b \cdot b\right) - 1\right) \]
  3. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy99.7%
Cost7424
\[-1 + \left({\left(b \cdot b + a \cdot a\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) \]
Alternative 2
Accuracy97.6%
Cost7305
\[\begin{array}{l} \mathbf{if}\;b \leq -0.116 \lor \neg \left(b \leq 4.2 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + b \cdot \left({b}^{3} + b \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]
Alternative 3
Accuracy97.7%
Cost7305
\[\begin{array}{l} \mathbf{if}\;b \leq -0.116 \lor \neg \left(b \leq 4 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(4 \cdot \left(b \cdot b\right) + {b}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]
Alternative 4
Accuracy97.7%
Cost6921
\[\begin{array}{l} \mathbf{if}\;b \leq -0.116 \lor \neg \left(b \leq 4 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + \left(4 + \left(a \cdot a\right) \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;-1 + {a}^{4}\\ \end{array} \]
Alternative 5
Accuracy97.5%
Cost1353
\[\begin{array}{l} \mathbf{if}\;b \leq -0.116 \lor \neg \left(b \leq 3.6 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b + \left(4 + \left(a \cdot a\right) \cdot 2\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a + 1\right) \cdot \left(-1 + a \cdot a\right)\\ \end{array} \]
Alternative 6
Accuracy96.2%
Cost969
\[\begin{array}{l} \mathbf{if}\;b \leq -3.35 \lor \neg \left(b \leq 4.7 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a + 1\right) \cdot \left(-1 + a \cdot a\right)\\ \end{array} \]
Alternative 7
Accuracy97.4%
Cost969
\[\begin{array}{l} \mathbf{if}\;b \leq -0.122 \lor \neg \left(b \leq 4.5 \cdot 10^{-7}\right):\\ \;\;\;\;-1 + \left(b \cdot b\right) \cdot \left(4 + b \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot a + 1\right) \cdot \left(-1 + a \cdot a\right)\\ \end{array} \]
Alternative 8
Accuracy80.7%
Cost576
\[-1 + \left(b \cdot b\right) \cdot \left(b \cdot b\right) \]
Alternative 9
Accuracy64.6%
Cost448
\[-1 + 4 \cdot \left(b \cdot b\right) \]
Alternative 10
Accuracy63.0%
Cost64
\[-1 \]

Error

Reproduce?

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