Average Error: 0.5 → 0.4
Time: 7.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{\mathsf{hypot}\left(a1, 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{\mathsf{hypot}\left(a1, a2\right)}{\sqrt[3]{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r103646 = th;
        double r103647 = cos(r103646);
        double r103648 = 2.0;
        double r103649 = sqrt(r103648);
        double r103650 = r103647 / r103649;
        double r103651 = a1;
        double r103652 = r103651 * r103651;
        double r103653 = r103650 * r103652;
        double r103654 = a2;
        double r103655 = r103654 * r103654;
        double r103656 = r103650 * r103655;
        double r103657 = r103653 + r103656;
        return r103657;
}

double f(double a1, double a2, double th) {
        double r103658 = th;
        double r103659 = cos(r103658);
        double r103660 = a1;
        double r103661 = a2;
        double r103662 = hypot(r103660, r103661);
        double r103663 = r103659 * r103662;
        double r103664 = 2.0;
        double r103665 = sqrt(r103664);
        double r103666 = cbrt(r103665);
        double r103667 = r103666 * r103666;
        double r103668 = r103663 / r103667;
        double r103669 = r103662 / r103666;
        double r103670 = r103668 * r103669;
        return r103670;
}

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

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

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

Reproduce

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