Average Error: 0.6 → 0.5
Time: 36.1s
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 \cos th\right) \cdot \frac{a2}{\sqrt{2}} + \left(a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}\]
\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 \cos th\right) \cdot \frac{a2}{\sqrt{2}} + \left(a1 \cdot a1\right) \cdot \frac{\cos th}{\sqrt{2}}
double f(double a1, double a2, double th) {
        double r1763392 = th;
        double r1763393 = cos(r1763392);
        double r1763394 = 2.0;
        double r1763395 = sqrt(r1763394);
        double r1763396 = r1763393 / r1763395;
        double r1763397 = a1;
        double r1763398 = r1763397 * r1763397;
        double r1763399 = r1763396 * r1763398;
        double r1763400 = a2;
        double r1763401 = r1763400 * r1763400;
        double r1763402 = r1763396 * r1763401;
        double r1763403 = r1763399 + r1763402;
        return r1763403;
}

double f(double a1, double a2, double th) {
        double r1763404 = a2;
        double r1763405 = th;
        double r1763406 = cos(r1763405);
        double r1763407 = r1763404 * r1763406;
        double r1763408 = 2.0;
        double r1763409 = sqrt(r1763408);
        double r1763410 = r1763404 / r1763409;
        double r1763411 = r1763407 * r1763410;
        double r1763412 = a1;
        double r1763413 = r1763412 * r1763412;
        double r1763414 = r1763406 / r1763409;
        double r1763415 = r1763413 * r1763414;
        double r1763416 = r1763411 + r1763415;
        return r1763416;
}

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.6

    \[\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.6

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

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

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

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

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

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

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

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

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

Reproduce

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