Average Error: 0.2 → 0.1
Time: 20.2s
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(4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right) + \left(a + 1\right) \cdot \left(a \cdot a\right)\right) + {\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{3} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\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(4 \cdot \left(\left(b \cdot b\right) \cdot \left(1 - 3 \cdot a\right) + \left(a + 1\right) \cdot \left(a \cdot a\right)\right) + {\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)}^{3} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right) - 1
double f(double a, double b) {
        double r3699241 = a;
        double r3699242 = r3699241 * r3699241;
        double r3699243 = b;
        double r3699244 = r3699243 * r3699243;
        double r3699245 = r3699242 + r3699244;
        double r3699246 = 2.0;
        double r3699247 = pow(r3699245, r3699246);
        double r3699248 = 4.0;
        double r3699249 = 1.0;
        double r3699250 = r3699249 + r3699241;
        double r3699251 = r3699242 * r3699250;
        double r3699252 = 3.0;
        double r3699253 = r3699252 * r3699241;
        double r3699254 = r3699249 - r3699253;
        double r3699255 = r3699244 * r3699254;
        double r3699256 = r3699251 + r3699255;
        double r3699257 = r3699248 * r3699256;
        double r3699258 = r3699247 + r3699257;
        double r3699259 = r3699258 - r3699249;
        return r3699259;
}

double f(double a, double b) {
        double r3699260 = 4.0;
        double r3699261 = b;
        double r3699262 = r3699261 * r3699261;
        double r3699263 = 1.0;
        double r3699264 = 3.0;
        double r3699265 = a;
        double r3699266 = r3699264 * r3699265;
        double r3699267 = r3699263 - r3699266;
        double r3699268 = r3699262 * r3699267;
        double r3699269 = r3699265 + r3699263;
        double r3699270 = r3699265 * r3699265;
        double r3699271 = r3699269 * r3699270;
        double r3699272 = r3699268 + r3699271;
        double r3699273 = r3699260 * r3699272;
        double r3699274 = fma(r3699265, r3699265, r3699262);
        double r3699275 = sqrt(r3699274);
        double r3699276 = pow(r3699275, r3699264);
        double r3699277 = r3699276 * r3699275;
        double r3699278 = r3699273 + r3699277;
        double r3699279 = r3699278 - r3699263;
        return r3699279;
}

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. Using strategy rm
  3. Applied add-sqr-sqrt0.2

    \[\leadsto \left({\color{blue}{\left(\sqrt{a \cdot a + b \cdot b} \cdot \sqrt{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\]
  4. Applied unpow-prod-down0.2

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

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

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

    \[\leadsto \left(\color{blue}{\mathsf{fma}\left(a, a, b \cdot b\right) \cdot \mathsf{fma}\left(a, a, b \cdot b\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. Using strategy rm
  10. Applied add-sqr-sqrt0.2

    \[\leadsto \left(\color{blue}{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)}\right)} \cdot \mathsf{fma}\left(a, a, b \cdot b\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. Applied associate-*l*0.1

    \[\leadsto \left(\color{blue}{\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \mathsf{fma}\left(a, a, b \cdot b\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\]
  12. Using strategy rm
  13. Applied add-sqr-sqrt0.1

    \[\leadsto \left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \color{blue}{\left(\sqrt{\mathsf{fma}\left(a, a, b \cdot b\right)} \cdot \sqrt{\mathsf{fma}\left(a, a, b \cdot b\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\]
  14. Applied cube-unmult0.1

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

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

Reproduce

herbie shell --seed 2019151 +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))