Average Error: 0.5 → 0.5
Time: 23.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 \mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}{\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{\cos th \cdot \mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}{\sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r72446 = th;
        double r72447 = cos(r72446);
        double r72448 = 2.0;
        double r72449 = sqrt(r72448);
        double r72450 = r72447 / r72449;
        double r72451 = a1;
        double r72452 = r72451 * r72451;
        double r72453 = r72450 * r72452;
        double r72454 = a2;
        double r72455 = r72454 * r72454;
        double r72456 = r72450 * r72455;
        double r72457 = r72453 + r72456;
        return r72457;
}

double f(double a1, double a2, double th) {
        double r72458 = th;
        double r72459 = cos(r72458);
        double r72460 = a1;
        double r72461 = a2;
        double r72462 = hypot(r72460, r72461);
        double r72463 = r72459 * r72462;
        double r72464 = 2.0;
        double r72465 = sqrt(r72464);
        double r72466 = cbrt(r72465);
        double r72467 = r72466 * r72466;
        double r72468 = r72463 / r72467;
        double r72469 = r72461 * r72461;
        double r72470 = fma(r72460, r72460, r72469);
        double r72471 = sqrt(r72470);
        double r72472 = r72471 / r72466;
        double r72473 = r72468 * r72472;
        return r72473;
}

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 *-un-lft-identity0.5

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

    \[\leadsto \frac{\cos th \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\color{blue}{\sqrt{1} \cdot \sqrt{2}}}\]
  6. Applied times-frac0.5

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

    \[\leadsto \color{blue}{\cos th} \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{2}}\]
  8. Using strategy rm
  9. Applied *-un-lft-identity0.5

    \[\leadsto \cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{\color{blue}{1 \cdot 2}}}\]
  10. Applied sqrt-prod0.5

    \[\leadsto \cos th \cdot \frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\color{blue}{\sqrt{1} \cdot \sqrt{2}}}\]
  11. Applied add-sqr-sqrt0.5

    \[\leadsto \cos th \cdot \frac{\color{blue}{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)} \cdot \sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}}{\sqrt{1} \cdot \sqrt{2}}\]
  12. Applied times-frac0.5

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

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

    \[\leadsto \color{blue}{\left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right)} \cdot \frac{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}{\sqrt{2}}\]
  15. Using strategy rm
  16. Applied add-cube-cbrt0.5

    \[\leadsto \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \frac{\sqrt{\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}}}}\]
  17. Applied *-un-lft-identity0.5

    \[\leadsto \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \frac{\sqrt{\color{blue}{1 \cdot \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}}\]
  18. Applied sqrt-prod0.5

    \[\leadsto \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \frac{\color{blue}{\sqrt{1} \cdot \sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}}{\left(\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}\right) \cdot \sqrt[3]{\sqrt{2}}}\]
  19. Applied times-frac0.6

    \[\leadsto \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \color{blue}{\left(\frac{\sqrt{1}}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}{\sqrt[3]{\sqrt{2}}}\right)}\]
  20. Applied associate-*r*0.6

    \[\leadsto \color{blue}{\left(\left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \frac{\sqrt{1}}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}\right) \cdot \frac{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}{\sqrt[3]{\sqrt{2}}}}\]
  21. Simplified0.5

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

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

Reproduce

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