Average Error: 0.5 → 0.5
Time: 25.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(\frac{\frac{a1}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} \cdot a1\right) \cdot \cos th + \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\cos th}{\sqrt{2}}\right)\right) \cdot \left(a2 \cdot a2\right)\]
\frac{\cos th}{\sqrt{2}} \cdot \left(a1 \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)
\left(\frac{\frac{a1}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}} \cdot a1\right) \cdot \cos th + \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\cos th}{\sqrt{2}}\right)\right) \cdot \left(a2 \cdot a2\right)
double f(double a1, double a2, double th) {
        double r3064025 = th;
        double r3064026 = cos(r3064025);
        double r3064027 = 2.0;
        double r3064028 = sqrt(r3064027);
        double r3064029 = r3064026 / r3064028;
        double r3064030 = a1;
        double r3064031 = r3064030 * r3064030;
        double r3064032 = r3064029 * r3064031;
        double r3064033 = a2;
        double r3064034 = r3064033 * r3064033;
        double r3064035 = r3064029 * r3064034;
        double r3064036 = r3064032 + r3064035;
        return r3064036;
}

double f(double a1, double a2, double th) {
        double r3064037 = a1;
        double r3064038 = 2.0;
        double r3064039 = sqrt(r3064038);
        double r3064040 = sqrt(r3064039);
        double r3064041 = r3064037 / r3064040;
        double r3064042 = r3064041 / r3064040;
        double r3064043 = r3064042 * r3064037;
        double r3064044 = th;
        double r3064045 = cos(r3064044);
        double r3064046 = r3064043 * r3064045;
        double r3064047 = r3064045 / r3064039;
        double r3064048 = expm1(r3064047);
        double r3064049 = log1p(r3064048);
        double r3064050 = a2;
        double r3064051 = r3064050 * r3064050;
        double r3064052 = r3064049 * r3064051;
        double r3064053 = r3064046 + r3064052;
        return r3064053;
}

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{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}} \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  8. Applied sqrt-prod0.5

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

    \[\leadsto \cos th \cdot \left(\color{blue}{\frac{\frac{a1}{\sqrt{\sqrt{2}}}}{\sqrt{\sqrt{2}}}} \cdot a1\right) + \frac{\cos th}{\sqrt{2}} \cdot \left(a2 \cdot a2\right)\]
  10. Using strategy rm
  11. Applied log1p-expm1-u0.5

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

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

Reproduce

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