\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\left(0.5 \cdot \cos re\right) \cdot \left(\left(-\mathsf{fma}\left({im}^{3}, \frac{1}{3}, \frac{1}{60} \cdot {im}^{5}\right)\right) - 2 \cdot im\right)double f(double re, double im) {
double r189977 = 0.5;
double r189978 = re;
double r189979 = cos(r189978);
double r189980 = r189977 * r189979;
double r189981 = 0.0;
double r189982 = im;
double r189983 = r189981 - r189982;
double r189984 = exp(r189983);
double r189985 = exp(r189982);
double r189986 = r189984 - r189985;
double r189987 = r189980 * r189986;
return r189987;
}
double f(double re, double im) {
double r189988 = 0.5;
double r189989 = re;
double r189990 = cos(r189989);
double r189991 = r189988 * r189990;
double r189992 = im;
double r189993 = 3.0;
double r189994 = pow(r189992, r189993);
double r189995 = 0.3333333333333333;
double r189996 = 0.016666666666666666;
double r189997 = 5.0;
double r189998 = pow(r189992, r189997);
double r189999 = r189996 * r189998;
double r190000 = fma(r189994, r189995, r189999);
double r190001 = -r190000;
double r190002 = 2.0;
double r190003 = r190002 * r189992;
double r190004 = r190001 - r190003;
double r190005 = r189991 * r190004;
return r190005;
}




Bits error versus re




Bits error versus im
| Original | 58.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
Initial program 58.0
Taylor expanded around 0 0.7
Simplified0.7
rmApplied fma-udef0.7
Applied associate--r+0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2019344 +o rules:numerics
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))