Average Error: 0.5 → 0.4
Time: 8.0s
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{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\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{\frac{\mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right)}{\sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r105904 = th;
        double r105905 = cos(r105904);
        double r105906 = 2.0;
        double r105907 = sqrt(r105906);
        double r105908 = r105905 / r105907;
        double r105909 = a1;
        double r105910 = r105909 * r105909;
        double r105911 = r105908 * r105910;
        double r105912 = a2;
        double r105913 = r105912 * r105912;
        double r105914 = r105908 * r105913;
        double r105915 = r105911 + r105914;
        return r105915;
}

double f(double a1, double a2, double th) {
        double r105916 = a1;
        double r105917 = a2;
        double r105918 = hypot(r105916, r105917);
        double r105919 = 2.0;
        double r105920 = sqrt(r105919);
        double r105921 = cbrt(r105920);
        double r105922 = r105921 * r105921;
        double r105923 = r105918 / r105922;
        double r105924 = th;
        double r105925 = cos(r105924);
        double r105926 = r105925 * r105918;
        double r105927 = r105923 * r105926;
        double r105928 = r105927 / r105921;
        return r105928;
}

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. 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 associate-/l*0.8

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

    \[\leadsto \frac{\cos th}{\frac{\sqrt{2}}{\color{blue}{\sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)} \cdot \sqrt{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}}}}\]
  7. Applied add-cube-cbrt0.8

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

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

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

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

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

    \[\leadsto \frac{\mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \color{blue}{\frac{\cos th \cdot \mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}}}}\]
  13. Using strategy rm
  14. Applied associate-*r/0.4

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

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

Reproduce

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