Average Error: 0.6 → 0.5
Time: 7.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{\cos th \cdot {\left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)\right)}^{1}}{\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{\cos th \cdot {\left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)\right)}^{1}}{\sqrt{2}}
double f(double a1, double a2, double th) {
        double r113437 = th;
        double r113438 = cos(r113437);
        double r113439 = 2.0;
        double r113440 = sqrt(r113439);
        double r113441 = r113438 / r113440;
        double r113442 = a1;
        double r113443 = r113442 * r113442;
        double r113444 = r113441 * r113443;
        double r113445 = a2;
        double r113446 = r113445 * r113445;
        double r113447 = r113441 * r113446;
        double r113448 = r113444 + r113447;
        return r113448;
}

double f(double a1, double a2, double th) {
        double r113449 = th;
        double r113450 = cos(r113449);
        double r113451 = a1;
        double r113452 = a2;
        double r113453 = r113452 * r113452;
        double r113454 = fma(r113451, r113451, r113453);
        double r113455 = 1.0;
        double r113456 = pow(r113454, r113455);
        double r113457 = r113450 * r113456;
        double r113458 = 2.0;
        double r113459 = sqrt(r113458);
        double r113460 = r113457 / r113459;
        return r113460;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Derivation

  1. Initial program 0.6

    \[\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 pow10.5

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

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

Reproduce

herbie shell --seed 2020057 +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))))