Average Error: 0.5 → 0.5
Time: 22.5s
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{\frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}} \cdot \cos th\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\frac{\frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}} \cdot \cos th
double f(double a1, double a2, double th) {
        double r80271 = th;
        double r80272 = cos(r80271);
        double r80273 = 2.0;
        double r80274 = sqrt(r80273);
        double r80275 = r80272 / r80274;
        double r80276 = a1;
        double r80277 = r80276 * r80276;
        double r80278 = r80275 * r80277;
        double r80279 = a2;
        double r80280 = r80279 * r80279;
        double r80281 = r80275 * r80280;
        double r80282 = r80278 + r80281;
        return r80282;
}

double f(double a1, double a2, double th) {
        double r80283 = a1;
        double r80284 = a2;
        double r80285 = r80284 * r80284;
        double r80286 = fma(r80283, r80283, r80285);
        double r80287 = 2.0;
        double r80288 = sqrt(r80287);
        double r80289 = cbrt(r80288);
        double r80290 = r80289 * r80289;
        double r80291 = r80286 / r80290;
        double r80292 = r80291 / r80289;
        double r80293 = th;
        double r80294 = cos(r80293);
        double r80295 = r80292 * r80294;
        return r80295;
}

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}{\cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}}\]
  3. Using strategy rm
  4. Applied add-cube-cbrt0.5

    \[\leadsto \cos th \cdot \frac{\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 \cos th \cdot \color{blue}{\frac{\frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}}}}\]
  6. Final simplification0.5

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

Reproduce

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