Average Error: 0.2 → 0.1
Time: 25.3s
Precision: 64
\[\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{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left({a}^{4}\right)\right)\right)\right) + 4 \cdot \left(\left(1 - a \cdot 3\right) \cdot \left(b \cdot b\right) + \left(a \cdot a\right) \cdot \left(1 + a\right)\right)\right) - 1\]
\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{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left({a}^{4}\right)\right)\right)\right) + 4 \cdot \left(\left(1 - a \cdot 3\right) \cdot \left(b \cdot b\right) + \left(a \cdot a\right) \cdot \left(1 + a\right)\right)\right) - 1
double f(double a, double b) {
        double r4077468 = a;
        double r4077469 = r4077468 * r4077468;
        double r4077470 = b;
        double r4077471 = r4077470 * r4077470;
        double r4077472 = r4077469 + r4077471;
        double r4077473 = 2.0;
        double r4077474 = pow(r4077472, r4077473);
        double r4077475 = 4.0;
        double r4077476 = 1.0;
        double r4077477 = r4077476 + r4077468;
        double r4077478 = r4077469 * r4077477;
        double r4077479 = 3.0;
        double r4077480 = r4077479 * r4077468;
        double r4077481 = r4077476 - r4077480;
        double r4077482 = r4077471 * r4077481;
        double r4077483 = r4077478 + r4077482;
        double r4077484 = r4077475 * r4077483;
        double r4077485 = r4077474 + r4077484;
        double r4077486 = r4077485 - r4077476;
        return r4077486;
}

double f(double a, double b) {
        double r4077487 = b;
        double r4077488 = r4077487 * r4077487;
        double r4077489 = a;
        double r4077490 = r4077489 * r4077489;
        double r4077491 = r4077490 * r4077488;
        double r4077492 = 2.0;
        double r4077493 = 4.0;
        double r4077494 = pow(r4077489, r4077493);
        double r4077495 = fma(r4077491, r4077492, r4077494);
        double r4077496 = fma(r4077488, r4077488, r4077495);
        double r4077497 = 1.0;
        double r4077498 = 3.0;
        double r4077499 = r4077489 * r4077498;
        double r4077500 = r4077497 - r4077499;
        double r4077501 = r4077500 * r4077488;
        double r4077502 = r4077497 + r4077489;
        double r4077503 = r4077490 * r4077502;
        double r4077504 = r4077501 + r4077503;
        double r4077505 = r4077493 * r4077504;
        double r4077506 = r4077496 + r4077505;
        double r4077507 = r4077506 - r4077497;
        return r4077507;
}

Error

Bits error versus a

Bits error versus b

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. Taylor expanded around inf 0.0

    \[\leadsto \left(\color{blue}{\left({b}^{4} + \left({a}^{4} + 2 \cdot \left({a}^{2} \cdot {b}^{2}\right)\right)\right)} + 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\]
  3. Simplified0.2

    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left(\left(a \cdot a\right) \cdot \left(a \cdot a\right)\right)\right)\right)\right)} + 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\]
  4. Using strategy rm
  5. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left(\left(a \cdot a\right) \cdot \left(\color{blue}{{a}^{1}} \cdot a\right)\right)\right)\right)\right) + 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\]
  6. Applied pow-plus0.2

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left(\left(a \cdot a\right) \cdot \color{blue}{{a}^{\left(1 + 1\right)}}\right)\right)\right)\right) + 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\]
  7. Applied pow10.2

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left(\left(\color{blue}{{a}^{1}} \cdot a\right) \cdot {a}^{\left(1 + 1\right)}\right)\right)\right)\right) + 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\]
  8. Applied pow-plus0.2

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left(\color{blue}{{a}^{\left(1 + 1\right)}} \cdot {a}^{\left(1 + 1\right)}\right)\right)\right)\right) + 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\]
  9. Applied pow-prod-up0.1

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \color{blue}{\left({a}^{\left(\left(1 + 1\right) + \left(1 + 1\right)\right)}\right)}\right)\right)\right) + 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\]
  10. Simplified0.1

    \[\leadsto \left(\mathsf{fma}\left(\left(b \cdot b\right), \left(b \cdot b\right), \left(\mathsf{fma}\left(\left(\left(a \cdot a\right) \cdot \left(b \cdot b\right)\right), 2, \left({a}^{\color{blue}{4}}\right)\right)\right)\right) + 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\]
  11. Final simplification0.1

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

Reproduce

herbie shell --seed 2019130 +o rules:numerics
(FPCore (a b)
  :name "Bouland and Aaronson, Equation (25)"
  (- (+ (pow (+ (* a a) (* b b)) 2) (* 4 (+ (* (* a a) (+ 1 a)) (* (* b b) (- 1 (* 3 a)))))) 1))