Average Error: 0.5 → 0.4
Time: 20.9s
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(a2 \cdot a2\right)}{\sqrt{2}} + \frac{a1 \cdot \left(a1 \cdot \cos th\right)}{\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(a2 \cdot a2\right)}{\sqrt{2}} + \frac{a1 \cdot \left(a1 \cdot \cos th\right)}{\sqrt{2}}
double f(double a1, double a2, double th) {
        double r1103354 = th;
        double r1103355 = cos(r1103354);
        double r1103356 = 2.0;
        double r1103357 = sqrt(r1103356);
        double r1103358 = r1103355 / r1103357;
        double r1103359 = a1;
        double r1103360 = r1103359 * r1103359;
        double r1103361 = r1103358 * r1103360;
        double r1103362 = a2;
        double r1103363 = r1103362 * r1103362;
        double r1103364 = r1103358 * r1103363;
        double r1103365 = r1103361 + r1103364;
        return r1103365;
}

double f(double a1, double a2, double th) {
        double r1103366 = th;
        double r1103367 = cos(r1103366);
        double r1103368 = a2;
        double r1103369 = r1103368 * r1103368;
        double r1103370 = r1103367 * r1103369;
        double r1103371 = 2.0;
        double r1103372 = sqrt(r1103371);
        double r1103373 = r1103370 / r1103372;
        double r1103374 = a1;
        double r1103375 = r1103374 * r1103367;
        double r1103376 = r1103374 * r1103375;
        double r1103377 = r1103376 / r1103372;
        double r1103378 = r1103373 + r1103377;
        return r1103378;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus th

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Using strategy rm
  3. Applied div-inv0.5

    \[\leadsto \color{blue}{\left(\cos th \cdot \frac{1}{\sqrt{2}}\right)} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  4. Applied associate-*l*0.5

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

    \[\leadsto \cos th \cdot \color{blue}{\frac{a1 \cdot a1}{\sqrt{2}}} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  6. Using strategy rm
  7. Applied associate-*l/0.5

    \[\leadsto \cos th \cdot \frac{a1 \cdot a1}{\sqrt{2}} + \color{blue}{\frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}}\]
  8. Using strategy rm
  9. Applied associate-*r/0.5

    \[\leadsto \color{blue}{\frac{\cos th \cdot \left(a1 \cdot a1\right)}{\sqrt{2}}} + \frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\]
  10. Using strategy rm
  11. Applied associate-*r*0.4

    \[\leadsto \frac{\color{blue}{\left(\cos th \cdot a1\right) \cdot a1}}{\sqrt{2}} + \frac{\cos th \cdot \left(a2 \cdot a2\right)}{\sqrt{2}}\]
  12. Final simplification0.4

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

Reproduce

herbie shell --seed 2019153 
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  (+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))