Average Error: 0.2 → 0.0
Time: 5.5s
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(3 + a\right)\right)\right) - 1\]
\[\mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(2 \cdot 2\right)} - 1\right)\]
\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(3 + a\right)\right)\right) - 1
\mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(2 \cdot 2\right)} - 1\right)
double f(double a, double b) {
        double r388251 = a;
        double r388252 = r388251 * r388251;
        double r388253 = b;
        double r388254 = r388253 * r388253;
        double r388255 = r388252 + r388254;
        double r388256 = 2.0;
        double r388257 = pow(r388255, r388256);
        double r388258 = 4.0;
        double r388259 = 1.0;
        double r388260 = r388259 - r388251;
        double r388261 = r388252 * r388260;
        double r388262 = 3.0;
        double r388263 = r388262 + r388251;
        double r388264 = r388254 * r388263;
        double r388265 = r388261 + r388264;
        double r388266 = r388258 * r388265;
        double r388267 = r388257 + r388266;
        double r388268 = r388267 - r388259;
        return r388268;
}

double f(double a, double b) {
        double r388269 = 4.0;
        double r388270 = b;
        double r388271 = 3.0;
        double r388272 = r388270 * r388271;
        double r388273 = a;
        double r388274 = r388273 * r388273;
        double r388275 = 1.0;
        double r388276 = r388275 - r388273;
        double r388277 = r388274 * r388276;
        double r388278 = fma(r388272, r388270, r388277);
        double r388279 = hypot(r388273, r388270);
        double r388280 = 2.0;
        double r388281 = 2.0;
        double r388282 = r388280 * r388281;
        double r388283 = pow(r388279, r388282);
        double r388284 = r388283 - r388275;
        double r388285 = fma(r388269, r388278, r388284);
        return r388285;
}

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(3 + a\right)\right)\right) - 1\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(4, \mathsf{fma}\left(a \cdot a, 1 - a, \left(b \cdot b\right) \cdot \left(3 + a\right)\right), {\left(a \cdot a + b \cdot b\right)}^{2} - 1\right)}\]
  3. Taylor expanded around 0 0.2

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

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

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

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

    \[\leadsto \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\left(\mathsf{hypot}\left(a, b\right) \cdot \color{blue}{\mathsf{hypot}\left(a, b\right)}\right)}^{2} - 1\right)\]
  9. Using strategy rm
  10. Applied pow10.2

    \[\leadsto \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\left(\mathsf{hypot}\left(a, b\right) \cdot \color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{1}}\right)}^{2} - 1\right)\]
  11. Applied pow10.2

    \[\leadsto \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\left(\color{blue}{{\left(\mathsf{hypot}\left(a, b\right)\right)}^{1}} \cdot {\left(\mathsf{hypot}\left(a, b\right)\right)}^{1}\right)}^{2} - 1\right)\]
  12. Applied pow-prod-up0.2

    \[\leadsto \mathsf{fma}\left(4, \mathsf{fma}\left(b \cdot 3, b, \left(a \cdot a\right) \cdot \left(1 - a\right)\right), {\color{blue}{\left({\left(\mathsf{hypot}\left(a, b\right)\right)}^{\left(1 + 1\right)}\right)}}^{2} - 1\right)\]
  13. Applied pow-pow0.0

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

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

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

Reproduce

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