\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(-\mathsf{fma}\left(\frac{1}{3}, {im}^{3}, \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)\right)double f(double re, double im) {
double r229271 = 0.5;
double r229272 = re;
double r229273 = sin(r229272);
double r229274 = r229271 * r229273;
double r229275 = im;
double r229276 = -r229275;
double r229277 = exp(r229276);
double r229278 = exp(r229275);
double r229279 = r229277 - r229278;
double r229280 = r229274 * r229279;
return r229280;
}
double f(double re, double im) {
double r229281 = 0.5;
double r229282 = re;
double r229283 = sin(r229282);
double r229284 = r229281 * r229283;
double r229285 = 0.3333333333333333;
double r229286 = im;
double r229287 = 3.0;
double r229288 = pow(r229286, r229287);
double r229289 = 0.016666666666666666;
double r229290 = 5.0;
double r229291 = pow(r229286, r229290);
double r229292 = 2.0;
double r229293 = r229292 * r229286;
double r229294 = fma(r229289, r229291, r229293);
double r229295 = fma(r229285, r229288, r229294);
double r229296 = -r229295;
double r229297 = r229284 * r229296;
return r229297;
}




Bits error versus re




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