Average Error: 0.5 → 0.5
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)\]
\[\mathsf{fma}\left(\frac{a1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{a1}{\sqrt[3]{\sqrt{2}}}, \cos th, \left(a2 \cdot \cos th\right) \cdot \frac{{a2}^{1}}{\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)
\mathsf{fma}\left(\frac{a1}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}} \cdot \frac{a1}{\sqrt[3]{\sqrt{2}}}, \cos th, \left(a2 \cdot \cos th\right) \cdot \frac{{a2}^{1}}{\sqrt{2}}\right)
double f(double a1, double a2, double th) {
        double r91000 = th;
        double r91001 = cos(r91000);
        double r91002 = 2.0;
        double r91003 = sqrt(r91002);
        double r91004 = r91001 / r91003;
        double r91005 = a1;
        double r91006 = r91005 * r91005;
        double r91007 = r91004 * r91006;
        double r91008 = a2;
        double r91009 = r91008 * r91008;
        double r91010 = r91004 * r91009;
        double r91011 = r91007 + r91010;
        return r91011;
}

double f(double a1, double a2, double th) {
        double r91012 = a1;
        double r91013 = 2.0;
        double r91014 = sqrt(r91013);
        double r91015 = cbrt(r91014);
        double r91016 = r91015 * r91015;
        double r91017 = r91012 / r91016;
        double r91018 = r91012 / r91015;
        double r91019 = r91017 * r91018;
        double r91020 = th;
        double r91021 = cos(r91020);
        double r91022 = a2;
        double r91023 = r91022 * r91021;
        double r91024 = 1.0;
        double r91025 = pow(r91022, r91024);
        double r91026 = r91025 / r91014;
        double r91027 = r91023 * r91026;
        double r91028 = fma(r91019, r91021, r91027);
        return r91028;
}

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. Taylor expanded around inf 0.5

    \[\leadsto \color{blue}{\frac{\cos th \cdot {a2}^{2}}{\sqrt{2}} + \frac{{a1}^{2} \cdot \cos th}{\sqrt{2}}}\]
  4. Simplified0.5

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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