\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left({im}^{5}, \sin re \cdot 0.008333333333333333, \mathsf{fma}\left(\sin re \cdot im, 1.0, \sin re \cdot \left(\left(\left(im \cdot im\right) \cdot im\right) \cdot 0.16666666666666666\right)\right)\right)double f(double re, double im) {
double r3087260 = 0.5;
double r3087261 = re;
double r3087262 = sin(r3087261);
double r3087263 = r3087260 * r3087262;
double r3087264 = im;
double r3087265 = -r3087264;
double r3087266 = exp(r3087265);
double r3087267 = exp(r3087264);
double r3087268 = r3087266 - r3087267;
double r3087269 = r3087263 * r3087268;
return r3087269;
}
double f(double re, double im) {
double r3087270 = im;
double r3087271 = 5.0;
double r3087272 = pow(r3087270, r3087271);
double r3087273 = re;
double r3087274 = sin(r3087273);
double r3087275 = 0.008333333333333333;
double r3087276 = r3087274 * r3087275;
double r3087277 = r3087274 * r3087270;
double r3087278 = 1.0;
double r3087279 = r3087270 * r3087270;
double r3087280 = r3087279 * r3087270;
double r3087281 = 0.16666666666666666;
double r3087282 = r3087280 * r3087281;
double r3087283 = r3087274 * r3087282;
double r3087284 = fma(r3087277, r3087278, r3087283);
double r3087285 = fma(r3087272, r3087276, r3087284);
double r3087286 = -r3087285;
return r3087286;
}




Bits error versus re




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