Average Error: 0.5 → 0.4
Time: 20.6s
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(\frac{a2}{\sqrt{2}} \cdot a2\right) \cdot \cos th + \left(a1 \cdot \frac{a1}{\sqrt{2}}\right) \cdot \cos th\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\left(\frac{a2}{\sqrt{2}} \cdot a2\right) \cdot \cos th + \left(a1 \cdot \frac{a1}{\sqrt{2}}\right) \cdot \cos th
double f(double a1, double a2, double th) {
        double r728942 = th;
        double r728943 = cos(r728942);
        double r728944 = 2.0;
        double r728945 = sqrt(r728944);
        double r728946 = r728943 / r728945;
        double r728947 = a1;
        double r728948 = r728947 * r728947;
        double r728949 = r728946 * r728948;
        double r728950 = a2;
        double r728951 = r728950 * r728950;
        double r728952 = r728946 * r728951;
        double r728953 = r728949 + r728952;
        return r728953;
}

double f(double a1, double a2, double th) {
        double r728954 = a2;
        double r728955 = 2.0;
        double r728956 = sqrt(r728955);
        double r728957 = r728954 / r728956;
        double r728958 = r728957 * r728954;
        double r728959 = th;
        double r728960 = cos(r728959);
        double r728961 = r728958 * r728960;
        double r728962 = a1;
        double r728963 = r728962 / r728956;
        double r728964 = r728962 * r728963;
        double r728965 = r728964 * r728960;
        double r728966 = r728961 + r728965;
        return r728966;
}

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 div-inv0.5

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

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

    \[\leadsto \cos th \cdot \color{blue}{\left(\frac{a1}{\sqrt{2}} \cdot a1\right)} + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  6. Using strategy rm
  7. Applied div-inv0.5

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

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

    \[\leadsto \cos th \cdot \left(\frac{a1}{\sqrt{2}} \cdot a1\right) + \cos th \cdot \color{blue}{\frac{a2 \cdot a2}{\sqrt{2}}}\]
  10. Taylor expanded around 0 0.5

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

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

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

Reproduce

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