Average Error: 0.5 → 0.4
Time: 12.5s
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{\sqrt[3]{\frac{1}{2}} \cdot \left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot \cos th\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{\sqrt[3]{\frac{1}{2}} \cdot \left(\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot \cos th\right)}{\sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r93134 = th;
        double r93135 = cos(r93134);
        double r93136 = 2.0;
        double r93137 = sqrt(r93136);
        double r93138 = r93135 / r93137;
        double r93139 = a1;
        double r93140 = r93139 * r93139;
        double r93141 = r93138 * r93140;
        double r93142 = a2;
        double r93143 = r93142 * r93142;
        double r93144 = r93138 * r93143;
        double r93145 = r93141 + r93144;
        return r93145;
}

double f(double a1, double a2, double th) {
        double r93146 = 1.0;
        double r93147 = 2.0;
        double r93148 = r93146 / r93147;
        double r93149 = cbrt(r93148);
        double r93150 = a1;
        double r93151 = a2;
        double r93152 = r93151 * r93151;
        double r93153 = fma(r93150, r93150, r93152);
        double r93154 = th;
        double r93155 = cos(r93154);
        double r93156 = r93153 * r93155;
        double r93157 = r93149 * r93156;
        double r93158 = sqrt(r93147);
        double r93159 = cbrt(r93158);
        double r93160 = r93157 / r93159;
        return r93160;
}

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 add-sqr-sqrt0.5

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

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

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

    \[\leadsto \frac{\left(\mathsf{hypot}\left(a2, a1\right) \cdot \cos th\right) \cdot \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}}}}\]
  9. Applied associate-/r*0.5

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

    \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(a1, a1, a2 \cdot a2\right) \cdot \cos th}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}}}{\sqrt[3]{\sqrt{2}}}\]
  11. Taylor expanded around inf 0.6

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

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

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

Reproduce

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