Average Error: 0.5 → 0.5
Time: 40.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)\]
\[\left(a2 \cdot a2\right) \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} + a1 \cdot \left(a1 \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\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)
\left(a2 \cdot a2\right) \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} + a1 \cdot \left(a1 \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\right)
double f(double a1, double a2, double th) {
        double r2121746 = th;
        double r2121747 = cos(r2121746);
        double r2121748 = 2.0;
        double r2121749 = sqrt(r2121748);
        double r2121750 = r2121747 / r2121749;
        double r2121751 = a1;
        double r2121752 = r2121751 * r2121751;
        double r2121753 = r2121750 * r2121752;
        double r2121754 = a2;
        double r2121755 = r2121754 * r2121754;
        double r2121756 = r2121750 * r2121755;
        double r2121757 = r2121753 + r2121756;
        return r2121757;
}

double f(double a1, double a2, double th) {
        double r2121758 = a2;
        double r2121759 = r2121758 * r2121758;
        double r2121760 = th;
        double r2121761 = cos(r2121760);
        double r2121762 = 2.0;
        double r2121763 = sqrt(r2121762);
        double r2121764 = sqrt(r2121763);
        double r2121765 = r2121761 / r2121764;
        double r2121766 = r2121765 / r2121764;
        double r2121767 = r2121759 * r2121766;
        double r2121768 = a1;
        double r2121769 = r2121768 * r2121766;
        double r2121770 = r2121768 * r2121769;
        double r2121771 = r2121767 + r2121770;
        return r2121771;
}

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. Using strategy rm
  3. Applied associate-*r*0.5

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

    \[\leadsto \left(\frac{\cos th}{\sqrt{2}} \cdot a1\right) \cdot a1 + \frac{\cos th}{\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}} \cdot \left(a2 \cdot a2\right)\]
  6. Applied sqrt-prod0.5

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

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

    \[\leadsto \left(\frac{\cos th}{\sqrt{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}} \cdot a1\right) \cdot a1 + \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} \cdot \left(a2 \cdot a2\right)\]
  10. Applied sqrt-prod0.5

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

    \[\leadsto \left(\color{blue}{\frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}}} \cdot a1\right) \cdot a1 + \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} \cdot \left(a2 \cdot a2\right)\]
  12. Final simplification0.5

    \[\leadsto \left(a2 \cdot a2\right) \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} + a1 \cdot \left(a1 \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}}\right)\]

Reproduce

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