\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 r229963 = 0.5;
double r229964 = re;
double r229965 = sin(r229964);
double r229966 = r229963 * r229965;
double r229967 = im;
double r229968 = -r229967;
double r229969 = exp(r229968);
double r229970 = exp(r229967);
double r229971 = r229969 - r229970;
double r229972 = r229966 * r229971;
return r229972;
}
double f(double re, double im) {
double r229973 = 0.5;
double r229974 = re;
double r229975 = sin(r229974);
double r229976 = r229973 * r229975;
double r229977 = 0.3333333333333333;
double r229978 = im;
double r229979 = 3.0;
double r229980 = pow(r229978, r229979);
double r229981 = r229977 * r229980;
double r229982 = -r229981;
double r229983 = 0.016666666666666666;
double r229984 = 5.0;
double r229985 = pow(r229978, r229984);
double r229986 = 2.0;
double r229987 = r229986 * r229978;
double r229988 = fma(r229983, r229985, r229987);
double r229989 = r229982 - r229988;
double r229990 = r229976 * r229989;
return r229990;
}




Bits error versus re




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