Average Error: 0.2 → 1.5
Time: 4.1s
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
\[\begin{array}{l} \mathbf{if}\;a \cdot a \le 5.308167373422853179984591298240806742507 \cdot 10^{-16}:\\ \;\;\;\;\left(\mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot b, b, {a}^{4}\right) - 1\\ \end{array}\]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\begin{array}{l}
\mathbf{if}\;a \cdot a \le 5.308167373422853179984591298240806742507 \cdot 10^{-16}:\\
\;\;\;\;\left(\mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(4 \cdot b, b, {a}^{4}\right) - 1\\

\end{array}
double f(double a, double b) {
        double r298416 = a;
        double r298417 = r298416 * r298416;
        double r298418 = b;
        double r298419 = r298418 * r298418;
        double r298420 = r298417 + r298419;
        double r298421 = 2.0;
        double r298422 = pow(r298420, r298421);
        double r298423 = 4.0;
        double r298424 = r298423 * r298419;
        double r298425 = r298422 + r298424;
        double r298426 = 1.0;
        double r298427 = r298425 - r298426;
        return r298427;
}

double f(double a, double b) {
        double r298428 = a;
        double r298429 = r298428 * r298428;
        double r298430 = 5.308167373422853e-16;
        bool r298431 = r298429 <= r298430;
        double r298432 = 2.0;
        double r298433 = 2.0;
        double r298434 = pow(r298428, r298433);
        double r298435 = r298432 * r298434;
        double r298436 = b;
        double r298437 = pow(r298436, r298433);
        double r298438 = 4.0;
        double r298439 = pow(r298436, r298438);
        double r298440 = fma(r298435, r298437, r298439);
        double r298441 = 4.0;
        double r298442 = r298436 * r298436;
        double r298443 = r298441 * r298442;
        double r298444 = r298440 + r298443;
        double r298445 = 1.0;
        double r298446 = r298444 - r298445;
        double r298447 = r298441 * r298436;
        double r298448 = pow(r298428, r298438);
        double r298449 = fma(r298447, r298436, r298448);
        double r298450 = r298449 - r298445;
        double r298451 = r298431 ? r298446 : r298450;
        return r298451;
}

Error

Bits error versus a

Bits error versus b

Derivation

  1. Split input into 2 regimes
  2. if (* a a) < 5.308167373422853e-16

    1. Initial program 0.1

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
    2. Taylor expanded around 0 0.0

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

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

    if 5.308167373422853e-16 < (* a a)

    1. Initial program 0.5

      \[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
    2. Taylor expanded around 0 6.8

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(4 \cdot b, b, {a}^{4}\right) - 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot a \le 5.308167373422853179984591298240806742507 \cdot 10^{-16}:\\ \;\;\;\;\left(\mathsf{fma}\left(2 \cdot {a}^{2}, {b}^{2}, {b}^{4}\right) + 4 \cdot \left(b \cdot b\right)\right) - 1\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(4 \cdot b, b, {a}^{4}\right) - 1\\ \end{array}\]

Reproduce

herbie shell --seed 2019346 +o rules:numerics
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (26)"
  :precision binary64
  (- (+ (pow (+ (* a a) (* b b)) 2) (* 4 (* b b))) 1))