\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 r154892 = 0.5;
double r154893 = re;
double r154894 = sin(r154893);
double r154895 = r154892 * r154894;
double r154896 = im;
double r154897 = -r154896;
double r154898 = exp(r154897);
double r154899 = exp(r154896);
double r154900 = r154898 - r154899;
double r154901 = r154895 * r154900;
return r154901;
}
double f(double re, double im) {
double r154902 = 0.5;
double r154903 = re;
double r154904 = sin(r154903);
double r154905 = r154902 * r154904;
double r154906 = 0.3333333333333333;
double r154907 = im;
double r154908 = 3.0;
double r154909 = pow(r154907, r154908);
double r154910 = 0.016666666666666666;
double r154911 = 5.0;
double r154912 = pow(r154907, r154911);
double r154913 = 2.0;
double r154914 = r154913 * r154907;
double r154915 = fma(r154910, r154912, r154914);
double r154916 = fma(r154906, r154909, r154915);
double r154917 = -r154916;
double r154918 = r154905 * r154917;
return r154918;
}




Bits error versus re




Bits error versus im
| Original | 43.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.9
Taylor expanded around 0 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019209 +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.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))