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 r119691 = th;
        double r119692 = cos(r119691);
        double r119693 = 2.0;
        double r119694 = sqrt(r119693);
        double r119695 = r119692 / r119694;
        double r119696 = a1;
        double r119697 = r119696 * r119696;
        double r119698 = r119695 * r119697;
        double r119699 = a2;
        double r119700 = r119699 * r119699;
        double r119701 = r119695 * r119700;
        double r119702 = r119698 + r119701;
        return r119702;
}

double f(double a1, double a2, double th) {
        double r119703 = 1.0;
        double r119704 = th;
        double r119705 = cos(r119704);
        double r119706 = a1;
        double r119707 = a2;
        double r119708 = r119707 * r119707;
        double r119709 = fma(r119706, r119706, r119708);
        double r119710 = r119705 * r119709;
        double r119711 = 2.0;
        double r119712 = sqrt(r119711);
        double r119713 = cbrt(r119712);
        double r119714 = r119713 * r119713;
        double r119715 = r119710 / r119714;
        double r119716 = r119703 * r119715;
        double r119717 = r119716 / r119713;
        return r119717;
}

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))))