\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(0.16666666666666666 \cdot \sin re, im \cdot \left(im \cdot im\right), \mathsf{fma}\left(0.008333333333333333 \cdot \sin re, {im}^{5}, im \cdot \left(1.0 \cdot \sin re\right)\right)\right)double f(double re, double im) {
double r8145978 = 0.5;
double r8145979 = re;
double r8145980 = sin(r8145979);
double r8145981 = r8145978 * r8145980;
double r8145982 = im;
double r8145983 = -r8145982;
double r8145984 = exp(r8145983);
double r8145985 = exp(r8145982);
double r8145986 = r8145984 - r8145985;
double r8145987 = r8145981 * r8145986;
return r8145987;
}
double f(double re, double im) {
double r8145988 = 0.16666666666666666;
double r8145989 = re;
double r8145990 = sin(r8145989);
double r8145991 = r8145988 * r8145990;
double r8145992 = im;
double r8145993 = r8145992 * r8145992;
double r8145994 = r8145992 * r8145993;
double r8145995 = 0.008333333333333333;
double r8145996 = r8145995 * r8145990;
double r8145997 = 5.0;
double r8145998 = pow(r8145992, r8145997);
double r8145999 = 1.0;
double r8146000 = r8145999 * r8145990;
double r8146001 = r8145992 * r8146000;
double r8146002 = fma(r8145996, r8145998, r8146001);
double r8146003 = fma(r8145991, r8145994, r8146002);
double r8146004 = -r8146003;
return r8146004;
}




Bits error versus re




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