Average Error: 0.5 → 0.5
Time: 9.6s
Precision: 64
\[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
\[\frac{1 \cdot \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}}\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\frac{1 \cdot \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r119582 = th;
        double r119583 = cos(r119582);
        double r119584 = 2.0;
        double r119585 = sqrt(r119584);
        double r119586 = r119583 / r119585;
        double r119587 = a1;
        double r119588 = r119587 * r119587;
        double r119589 = r119586 * r119588;
        double r119590 = a2;
        double r119591 = r119590 * r119590;
        double r119592 = r119586 * r119591;
        double r119593 = r119589 + r119592;
        return r119593;
}

double f(double a1, double a2, double th) {
        double r119594 = 1.0;
        double r119595 = th;
        double r119596 = cos(r119595);
        double r119597 = a1;
        double r119598 = a2;
        double r119599 = r119598 * r119598;
        double r119600 = fma(r119597, r119597, r119599);
        double r119601 = r119596 * r119600;
        double r119602 = 2.0;
        double r119603 = sqrt(r119602);
        double r119604 = cbrt(r119603);
        double r119605 = r119604 * r119604;
        double r119606 = r119601 / r119605;
        double r119607 = r119594 * r119606;
        double r119608 = r119607 / r119604;
        return r119608;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Derivation

  1. Initial program 0.5

    \[\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  2. Simplified0.5

    \[\leadsto \color{blue}{\frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}}\]
  3. Using strategy rm
  4. Applied add-cube-cbrt0.5

    \[\leadsto \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\color{blue}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}}}\]
  5. Applied associate-/r*0.5

    \[\leadsto \color{blue}{\frac{\frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}}}\]
  6. Using strategy rm
  7. Applied *-un-lft-identity0.5

    \[\leadsto \frac{\color{blue}{1 \cdot \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}}{\sqrt[3]{\sqrt{2}}}\]
  8. Final simplification0.5

    \[\leadsto \frac{1 \cdot \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}}\]

Reproduce

herbie shell --seed 2020060 +o rules:numerics
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  :precision binary64
  (+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))