Average Error: 0.6 → 0.5
Time: 5.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{\cos th \cdot \left(1 \cdot \left({a2}^{2} + {a1}^{2}\right)\right)}{\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{\cos th \cdot \left(1 \cdot \left({a2}^{2} + {a1}^{2}\right)\right)}{\sqrt{2}}
double f(double a1, double a2, double th) {
        double r87128 = th;
        double r87129 = cos(r87128);
        double r87130 = 2.0;
        double r87131 = sqrt(r87130);
        double r87132 = r87129 / r87131;
        double r87133 = a1;
        double r87134 = r87133 * r87133;
        double r87135 = r87132 * r87134;
        double r87136 = a2;
        double r87137 = r87136 * r87136;
        double r87138 = r87132 * r87137;
        double r87139 = r87135 + r87138;
        return r87139;
}

double f(double a1, double a2, double th) {
        double r87140 = th;
        double r87141 = cos(r87140);
        double r87142 = 1.0;
        double r87143 = a2;
        double r87144 = 2.0;
        double r87145 = pow(r87143, r87144);
        double r87146 = a1;
        double r87147 = pow(r87146, r87144);
        double r87148 = r87145 + r87147;
        double r87149 = r87142 * r87148;
        double r87150 = r87141 * r87149;
        double r87151 = 2.0;
        double r87152 = sqrt(r87151);
        double r87153 = r87150 / r87152;
        return r87153;
}

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

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

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

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

    \[\leadsto \cos th \cdot \color{blue}{\frac{{a2}^{2} + {a1}^{2}}{\sqrt{2}}}\]
  7. Using strategy rm
  8. Applied associate-*r/0.5

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

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

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

Reproduce

herbie shell --seed 2020057 
(FPCore (a1 a2 th)
  :name "Migdal et al, Equation (64)"
  :precision binary64
  (+ (* (/ (cos th) (sqrt 2)) (* a1 a1)) (* (/ (cos th) (sqrt 2)) (* a2 a2))))