Average Error: 0.5 → 0.5
Time: 7.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)\]
\[\left(\left|a1\right| \cdot \cos th\right) \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \left(\left|a2\right| \cdot \frac{\left|a2\right|}{\sqrt{2}}\right)\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\left(\left|a1\right| \cdot \cos th\right) \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \left(\left|a2\right| \cdot \frac{\left|a2\right|}{\sqrt{2}}\right)
double f(double a1, double a2, double th) {
        double r97327 = th;
        double r97328 = cos(r97327);
        double r97329 = 2.0;
        double r97330 = sqrt(r97329);
        double r97331 = r97328 / r97330;
        double r97332 = a1;
        double r97333 = r97332 * r97332;
        double r97334 = r97331 * r97333;
        double r97335 = a2;
        double r97336 = r97335 * r97335;
        double r97337 = r97331 * r97336;
        double r97338 = r97334 + r97337;
        return r97338;
}

double f(double a1, double a2, double th) {
        double r97339 = a1;
        double r97340 = fabs(r97339);
        double r97341 = th;
        double r97342 = cos(r97341);
        double r97343 = r97340 * r97342;
        double r97344 = 2.0;
        double r97345 = pow(r97339, r97344);
        double r97346 = sqrt(r97345);
        double r97347 = 2.0;
        double r97348 = sqrt(r97347);
        double r97349 = r97346 / r97348;
        double r97350 = r97343 * r97349;
        double r97351 = a2;
        double r97352 = fabs(r97351);
        double r97353 = r97352 / r97348;
        double r97354 = r97352 * r97353;
        double r97355 = r97342 * r97354;
        double r97356 = r97350 + r97355;
        return r97356;
}

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 \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \color{blue}{\left(\cos th \cdot \frac{1}{\sqrt{2}}\right)} \cdot \left(a2 \cdot a2\right)\]
  4. Applied associate-*l*0.5

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

    \[\leadsto \frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \cos th \cdot \color{blue}{\frac{{a2}^{2}}{\sqrt{2}}}\]
  6. Using strategy rm
  7. Applied div-inv0.5

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

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

    \[\leadsto \cos th \cdot \color{blue}{\frac{{a1}^{2}}{\sqrt{2}}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{2}}\]
  10. Using strategy rm
  11. Applied *-un-lft-identity0.5

    \[\leadsto \cos th \cdot \frac{{a1}^{2}}{\sqrt{\color{blue}{1 \cdot 2}}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{2}}\]
  12. Applied sqrt-prod0.5

    \[\leadsto \cos th \cdot \frac{{a1}^{2}}{\color{blue}{\sqrt{1} \cdot \sqrt{2}}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{2}}\]
  13. Applied add-sqr-sqrt0.5

    \[\leadsto \cos th \cdot \frac{\color{blue}{\sqrt{{a1}^{2}} \cdot \sqrt{{a1}^{2}}}}{\sqrt{1} \cdot \sqrt{2}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{2}}\]
  14. Applied times-frac0.5

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

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

    \[\leadsto \color{blue}{\left(\left|a1\right| \cdot \cos th\right)} \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{2}}\]
  17. Using strategy rm
  18. Applied *-un-lft-identity0.5

    \[\leadsto \left(\left|a1\right| \cdot \cos th\right) \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \frac{{a2}^{2}}{\sqrt{\color{blue}{1 \cdot 2}}}\]
  19. Applied sqrt-prod0.5

    \[\leadsto \left(\left|a1\right| \cdot \cos th\right) \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \frac{{a2}^{2}}{\color{blue}{\sqrt{1} \cdot \sqrt{2}}}\]
  20. Applied add-sqr-sqrt0.5

    \[\leadsto \left(\left|a1\right| \cdot \cos th\right) \cdot \frac{\sqrt{{a1}^{2}}}{\sqrt{2}} + \cos th \cdot \frac{\color{blue}{\sqrt{{a2}^{2}} \cdot \sqrt{{a2}^{2}}}}{\sqrt{1} \cdot \sqrt{2}}\]
  21. Applied times-frac0.5

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

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

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

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

Reproduce

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