\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(\left(\mathsf{fma}\left({im}^{5}, \frac{-1}{60}, {im}^{3} \cdot \frac{-1}{3}\right) - 2 \cdot im\right) \cdot 0.5\right) \cdot \sin redouble f(double re, double im) {
double r134230 = 0.5;
double r134231 = re;
double r134232 = sin(r134231);
double r134233 = r134230 * r134232;
double r134234 = im;
double r134235 = -r134234;
double r134236 = exp(r134235);
double r134237 = exp(r134234);
double r134238 = r134236 - r134237;
double r134239 = r134233 * r134238;
return r134239;
}
double f(double re, double im) {
double r134240 = im;
double r134241 = 5.0;
double r134242 = pow(r134240, r134241);
double r134243 = -0.016666666666666666;
double r134244 = 3.0;
double r134245 = pow(r134240, r134244);
double r134246 = -0.3333333333333333;
double r134247 = r134245 * r134246;
double r134248 = fma(r134242, r134243, r134247);
double r134249 = 2.0;
double r134250 = r134249 * r134240;
double r134251 = r134248 - r134250;
double r134252 = 0.5;
double r134253 = r134251 * r134252;
double r134254 = re;
double r134255 = sin(r134254);
double r134256 = r134253 * r134255;
return r134256;
}




Bits error versus re




Bits error versus im
| Original | 43.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.7
Simplified43.7
Taylor expanded around 0 0.8
Simplified0.8
rmApplied fma-udef0.8
Applied associate--r+0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019194 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1.0) (- (* (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))))