Average Error: 0.2 → 0.2
Time: 20.7s
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
\[\mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}} \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}\right), -1\right)\right)\]
\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1
\mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}} \cdot \left(\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}\right), -1\right)\right)
double f(double a, double b) {
        double r5827156 = a;
        double r5827157 = r5827156 * r5827156;
        double r5827158 = b;
        double r5827159 = r5827158 * r5827158;
        double r5827160 = r5827157 + r5827159;
        double r5827161 = 2.0;
        double r5827162 = pow(r5827160, r5827161);
        double r5827163 = 4.0;
        double r5827164 = r5827163 * r5827159;
        double r5827165 = r5827162 + r5827164;
        double r5827166 = 1.0;
        double r5827167 = r5827165 - r5827166;
        return r5827167;
}

double f(double a, double b) {
        double r5827168 = 4.0;
        double r5827169 = b;
        double r5827170 = r5827169 * r5827169;
        double r5827171 = a;
        double r5827172 = r5827171 * r5827171;
        double r5827173 = fma(r5827169, r5827169, r5827172);
        double r5827174 = sqrt(r5827173);
        double r5827175 = sqrt(r5827174);
        double r5827176 = r5827175 * r5827174;
        double r5827177 = r5827175 * r5827176;
        double r5827178 = -1.0;
        double r5827179 = fma(r5827173, r5827177, r5827178);
        double r5827180 = fma(r5827168, r5827170, r5827179);
        return r5827180;
}

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. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b, b, a \cdot a\right), -1\right)\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.2

    \[\leadsto \mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \color{blue}{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}}, -1\right)\right)\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.2

    \[\leadsto \mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \sqrt{\color{blue}{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}}} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}, -1\right)\right)\]
  7. Applied sqrt-prod0.3

    \[\leadsto \mathsf{fma}\left(4, b \cdot b, \mathsf{fma}\left(\mathsf{fma}\left(b, b, a \cdot a\right), \color{blue}{\left(\sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}} \cdot \sqrt{\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}}\right)} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}, -1\right)\right)\]
  8. Applied associate-*l*0.2

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

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

Reproduce

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