\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(im \cdot \left(im \cdot im\right), \sin re \cdot 0.16666666666666666, \sin re \cdot \left(1.0 \cdot im + {im}^{5} \cdot 0.008333333333333333\right)\right)double f(double re, double im) {
double r7248256 = 0.5;
double r7248257 = re;
double r7248258 = sin(r7248257);
double r7248259 = r7248256 * r7248258;
double r7248260 = im;
double r7248261 = -r7248260;
double r7248262 = exp(r7248261);
double r7248263 = exp(r7248260);
double r7248264 = r7248262 - r7248263;
double r7248265 = r7248259 * r7248264;
return r7248265;
}
double f(double re, double im) {
double r7248266 = im;
double r7248267 = r7248266 * r7248266;
double r7248268 = r7248266 * r7248267;
double r7248269 = re;
double r7248270 = sin(r7248269);
double r7248271 = 0.16666666666666666;
double r7248272 = r7248270 * r7248271;
double r7248273 = 1.0;
double r7248274 = r7248273 * r7248266;
double r7248275 = 5.0;
double r7248276 = pow(r7248266, r7248275);
double r7248277 = 0.008333333333333333;
double r7248278 = r7248276 * r7248277;
double r7248279 = r7248274 + r7248278;
double r7248280 = r7248270 * r7248279;
double r7248281 = fma(r7248268, r7248272, r7248280);
double r7248282 = -r7248281;
return r7248282;
}




Bits error versus re




Bits error versus im
| Original | 43.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.8 |
Initial program 43.5
Taylor expanded around 0 0.8
Simplified0.8
Taylor expanded around inf 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019162 +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))))