\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 r361931 = 0.5;
double r361932 = re;
double r361933 = sin(r361932);
double r361934 = r361931 * r361933;
double r361935 = im;
double r361936 = -r361935;
double r361937 = exp(r361936);
double r361938 = exp(r361935);
double r361939 = r361937 - r361938;
double r361940 = r361934 * r361939;
return r361940;
}
double f(double re, double im) {
double r361941 = 0.5;
double r361942 = re;
double r361943 = sin(r361942);
double r361944 = r361941 * r361943;
double r361945 = 0.3333333333333333;
double r361946 = im;
double r361947 = 3.0;
double r361948 = pow(r361946, r361947);
double r361949 = r361945 * r361948;
double r361950 = -r361949;
double r361951 = 0.016666666666666666;
double r361952 = 5.0;
double r361953 = pow(r361946, r361952);
double r361954 = 2.0;
double r361955 = r361954 * r361946;
double r361956 = fma(r361951, r361953, r361955);
double r361957 = r361950 - r361956;
double r361958 = r361944 * r361957;
return r361958;
}




Bits error versus re




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