\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r279272 = 0.5;
double r279273 = re;
double r279274 = sin(r279273);
double r279275 = r279272 * r279274;
double r279276 = im;
double r279277 = -r279276;
double r279278 = exp(r279277);
double r279279 = exp(r279276);
double r279280 = r279278 - r279279;
double r279281 = r279275 * r279280;
return r279281;
}
double f(double re, double im) {
double r279282 = 0.5;
double r279283 = re;
double r279284 = sin(r279283);
double r279285 = r279282 * r279284;
double r279286 = 0.3333333333333333;
double r279287 = im;
double r279288 = 3.0;
double r279289 = pow(r279287, r279288);
double r279290 = r279286 * r279289;
double r279291 = -r279290;
double r279292 = 0.016666666666666666;
double r279293 = 5.0;
double r279294 = pow(r279287, r279293);
double r279295 = 2.0;
double r279296 = r279295 * r279287;
double r279297 = fma(r279292, r279294, r279296);
double r279298 = r279291 - r279297;
double r279299 = r279285 * r279298;
return r279299;
}




Bits error versus re




Bits error versus im
| Original | 43.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.9
Taylor expanded around 0 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2020065 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))