Average Error: 0.2 → 0.2
Time: 1.2m
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
\[\mathsf{fma}\left(b, \left(b \cdot 4\right), \left(\mathsf{fma}\left(\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), \left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), -1\right)\right)\right)\]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\mathsf{fma}\left(b, \left(b \cdot 4\right), \left(\mathsf{fma}\left(\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), \left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), -1\right)\right)\right)
double f(double a, double b) {
        double r50962703 = a;
        double r50962704 = r50962703 * r50962703;
        double r50962705 = b;
        double r50962706 = r50962705 * r50962705;
        double r50962707 = r50962704 + r50962706;
        double r50962708 = 2.0;
        double r50962709 = pow(r50962707, r50962708);
        double r50962710 = 4.0;
        double r50962711 = r50962710 * r50962706;
        double r50962712 = r50962709 + r50962711;
        double r50962713 = 1.0;
        double r50962714 = r50962712 - r50962713;
        return r50962714;
}

double f(double a, double b) {
        double r50962715 = b;
        double r50962716 = 4.0;
        double r50962717 = r50962715 * r50962716;
        double r50962718 = a;
        double r50962719 = hypot(r50962718, r50962715);
        double r50962720 = r50962719 * r50962719;
        double r50962721 = -1.0;
        double r50962722 = fma(r50962720, r50962720, r50962721);
        double r50962723 = fma(r50962715, r50962717, r50962722);
        return r50962723;
}

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(b \cdot b\right)\right) - 1\]
  2. Using strategy rm
  3. Applied *-un-lft-identity0.2

    \[\leadsto \left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - \color{blue}{1 \cdot 1}\]
  4. Applied add-sqr-sqrt0.2

    \[\leadsto \color{blue}{\sqrt{{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)} \cdot \sqrt{{\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)}} - 1 \cdot 1\]
  5. Applied prod-diff0.2

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

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

    \[\leadsto \mathsf{fma}\left(b, \left(4 \cdot b\right), \left(\mathsf{fma}\left(\left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), \left(\mathsf{hypot}\left(a, b\right) \cdot \mathsf{hypot}\left(a, b\right)\right), -1\right)\right)\right) + \color{blue}{0}\]
  8. Final simplification0.2

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

Reproduce

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