Average Error: 0.5 → 0.4
Time: 9.8s
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{1}{\sqrt{\sqrt{\sqrt{2}}}} \cdot \frac{\frac{\left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \mathsf{hypot}\left(a1, a2\right)}{\sqrt{\sqrt{\sqrt{2}}}}}{\sqrt{\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{1}{\sqrt{\sqrt{\sqrt{2}}}} \cdot \frac{\frac{\left(\cos th \cdot \mathsf{hypot}\left(a1, a2\right)\right) \cdot \mathsf{hypot}\left(a1, a2\right)}{\sqrt{\sqrt{\sqrt{2}}}}}{\sqrt{\sqrt{2}}}
double f(double a1, double a2, double th) {
        double r109676 = th;
        double r109677 = cos(r109676);
        double r109678 = 2.0;
        double r109679 = sqrt(r109678);
        double r109680 = r109677 / r109679;
        double r109681 = a1;
        double r109682 = r109681 * r109681;
        double r109683 = r109680 * r109682;
        double r109684 = a2;
        double r109685 = r109684 * r109684;
        double r109686 = r109680 * r109685;
        double r109687 = r109683 + r109686;
        return r109687;
}

double f(double a1, double a2, double th) {
        double r109688 = 1.0;
        double r109689 = 2.0;
        double r109690 = sqrt(r109689);
        double r109691 = sqrt(r109690);
        double r109692 = sqrt(r109691);
        double r109693 = r109688 / r109692;
        double r109694 = th;
        double r109695 = cos(r109694);
        double r109696 = a1;
        double r109697 = a2;
        double r109698 = hypot(r109696, r109697);
        double r109699 = r109695 * r109698;
        double r109700 = r109699 * r109698;
        double r109701 = r109700 / r109692;
        double r109702 = r109701 / r109691;
        double r109703 = r109693 * r109702;
        return r109703;
}

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 \mathsf{fma}\left(a1, a1, a2 \cdot a2\right)}{\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}}\]
  5. Applied sqrt-prod0.6

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

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

    \[\leadsto \frac{\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{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\]
  9. Applied associate-*r*0.5

    \[\leadsto \frac{\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{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\]
  10. Simplified0.5

    \[\leadsto \frac{\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{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\]
  11. Using strategy rm
  12. Applied add-sqr-sqrt0.5

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

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

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

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

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

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

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

Reproduce

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