Average Error: 0.5 → 0.5
Time: 24.2s
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{\left(\mathsf{hypot}\left(a2, a1\right) \cdot \cos th\right) \cdot \frac{\mathsf{hypot}\left(a2, a1\right)}{\sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}} \cdot \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{\left(\mathsf{hypot}\left(a2, a1\right) \cdot \cos th\right) \cdot \frac{\mathsf{hypot}\left(a2, a1\right)}{\sqrt[3]{\sqrt{2}}}}{\sqrt[3]{\sqrt{2}} \cdot \sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r78128 = th;
        double r78129 = cos(r78128);
        double r78130 = 2.0;
        double r78131 = sqrt(r78130);
        double r78132 = r78129 / r78131;
        double r78133 = a1;
        double r78134 = r78133 * r78133;
        double r78135 = r78132 * r78134;
        double r78136 = a2;
        double r78137 = r78136 * r78136;
        double r78138 = r78132 * r78137;
        double r78139 = r78135 + r78138;
        return r78139;
}

double f(double a1, double a2, double th) {
        double r78140 = a2;
        double r78141 = a1;
        double r78142 = hypot(r78140, r78141);
        double r78143 = th;
        double r78144 = cos(r78143);
        double r78145 = r78142 * r78144;
        double r78146 = 2.0;
        double r78147 = sqrt(r78146);
        double r78148 = cbrt(r78147);
        double r78149 = r78142 / r78148;
        double r78150 = r78145 * r78149;
        double r78151 = r78148 * r78148;
        double r78152 = r78150 / r78151;
        return r78152;
}

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.4

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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.4

    \[\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 times-frac0.4

    \[\leadsto \color{blue}{\frac{\mathsf{hypot}\left(a2, a1\right) \cdot \cos th}{\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}}}}\]
  10. Simplified0.4

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

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

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

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  (+ (* (/ (cos th) (sqrt 2.0)) (* a1 a1)) (* (/ (cos th) (sqrt 2.0)) (* a2 a2))))