\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r254897 = 0.5;
double r254898 = re;
double r254899 = sin(r254898);
double r254900 = r254897 * r254899;
double r254901 = im;
double r254902 = -r254901;
double r254903 = exp(r254902);
double r254904 = exp(r254901);
double r254905 = r254903 - r254904;
double r254906 = r254900 * r254905;
return r254906;
}
double f(double re, double im) {
double r254907 = 0.5;
double r254908 = re;
double r254909 = sin(r254908);
double r254910 = r254907 * r254909;
double r254911 = 0.3333333333333333;
double r254912 = im;
double r254913 = 3.0;
double r254914 = pow(r254912, r254913);
double r254915 = r254911 * r254914;
double r254916 = -r254915;
double r254917 = 0.016666666666666666;
double r254918 = 5.0;
double r254919 = pow(r254912, r254918);
double r254920 = 2.0;
double r254921 = r254920 * r254912;
double r254922 = fma(r254917, r254919, r254921);
double r254923 = r254916 - r254922;
double r254924 = r254910 * r254923;
return r254924;
}




Bits error versus re




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