Average Error: 0.2 → 0.2
Time: 25.3s
Precision: 64
\[\left({\left(a \cdot a + b \cdot b\right)}^{2} + 4 \cdot \left(b \cdot b\right)\right) - 1\]
\[\mathsf{fma}\left(\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}, \mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b \cdot b, 4, -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(\sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)} \cdot \sqrt{\mathsf{fma}\left(b, b, a \cdot a\right)}, \mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b \cdot b, 4, -1\right)\right)
double f(double a, double b) {
        double r4829164 = a;
        double r4829165 = r4829164 * r4829164;
        double r4829166 = b;
        double r4829167 = r4829166 * r4829166;
        double r4829168 = r4829165 + r4829167;
        double r4829169 = 2.0;
        double r4829170 = pow(r4829168, r4829169);
        double r4829171 = 4.0;
        double r4829172 = r4829171 * r4829167;
        double r4829173 = r4829170 + r4829172;
        double r4829174 = 1.0;
        double r4829175 = r4829173 - r4829174;
        return r4829175;
}

double f(double a, double b) {
        double r4829176 = b;
        double r4829177 = a;
        double r4829178 = r4829177 * r4829177;
        double r4829179 = fma(r4829176, r4829176, r4829178);
        double r4829180 = sqrt(r4829179);
        double r4829181 = r4829180 * r4829180;
        double r4829182 = r4829176 * r4829176;
        double r4829183 = 4.0;
        double r4829184 = -1.0;
        double r4829185 = fma(r4829182, r4829183, r4829184);
        double r4829186 = fma(r4829181, r4829179, r4829185);
        return r4829186;
}

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(\mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b, b, a \cdot a\right), \mathsf{fma}\left(b \cdot b, 4, -1\right)\right)}\]
  3. Using strategy rm
  4. Applied add-sqr-sqrt0.2

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

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

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

Reproduce

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