\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\mathsf{fma}\left(\left({im}^{5}\right), \frac{-1}{60}, \left(im \cdot \left(im \cdot \left(im \cdot \frac{-1}{3}\right) - 2\right)\right)\right) \cdot \left(0.5 \cdot \sin re\right)double f(double re, double im) {
double r31096967 = 0.5;
double r31096968 = re;
double r31096969 = sin(r31096968);
double r31096970 = r31096967 * r31096969;
double r31096971 = im;
double r31096972 = -r31096971;
double r31096973 = exp(r31096972);
double r31096974 = exp(r31096971);
double r31096975 = r31096973 - r31096974;
double r31096976 = r31096970 * r31096975;
return r31096976;
}
double f(double re, double im) {
double r31096977 = im;
double r31096978 = 5.0;
double r31096979 = pow(r31096977, r31096978);
double r31096980 = -0.016666666666666666;
double r31096981 = -0.3333333333333333;
double r31096982 = r31096977 * r31096981;
double r31096983 = r31096977 * r31096982;
double r31096984 = 2.0;
double r31096985 = r31096983 - r31096984;
double r31096986 = r31096977 * r31096985;
double r31096987 = fma(r31096979, r31096980, r31096986);
double r31096988 = 0.5;
double r31096989 = re;
double r31096990 = sin(r31096989);
double r31096991 = r31096988 * r31096990;
double r31096992 = r31096987 * r31096991;
return r31096992;
}




Bits error versus re




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