Average Error: 0.5 → 0.5
Time: 23.4s
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}}} + \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(a2 \cdot a2\right) \cdot \frac{\frac{\cos th}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} + \left(a1 \cdot \frac{a1}{\sqrt{2}}\right) \cdot \cos th
double f(double a1, double a2, double th) {
        double r849645 = th;
        double r849646 = cos(r849645);
        double r849647 = 2.0;
        double r849648 = sqrt(r849647);
        double r849649 = r849646 / r849648;
        double r849650 = a1;
        double r849651 = r849650 * r849650;
        double r849652 = r849649 * r849651;
        double r849653 = a2;
        double r849654 = r849653 * r849653;
        double r849655 = r849649 * r849654;
        double r849656 = r849652 + r849655;
        return r849656;
}

double f(double a1, double a2, double th) {
        double r849657 = a2;
        double r849658 = r849657 * r849657;
        double r849659 = th;
        double r849660 = cos(r849659);
        double r849661 = 2.0;
        double r849662 = sqrt(r849661);
        double r849663 = sqrt(r849662);
        double r849664 = r849660 / r849663;
        double r849665 = r849664 / r849663;
        double r849666 = r849658 * r849665;
        double r849667 = a1;
        double r849668 = r849667 / r849662;
        double r849669 = r849667 * r849668;
        double r849670 = r849669 * r849660;
        double r849671 = r849666 + r849670;
        return r849671;
}

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 add-sqr-sqrt0.5

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

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

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

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

Reproduce

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