\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 r200014 = 0.5;
double r200015 = re;
double r200016 = sin(r200015);
double r200017 = r200014 * r200016;
double r200018 = im;
double r200019 = -r200018;
double r200020 = exp(r200019);
double r200021 = exp(r200018);
double r200022 = r200020 - r200021;
double r200023 = r200017 * r200022;
return r200023;
}
double f(double re, double im) {
double r200024 = 0.5;
double r200025 = re;
double r200026 = sin(r200025);
double r200027 = r200024 * r200026;
double r200028 = 0.3333333333333333;
double r200029 = im;
double r200030 = 3.0;
double r200031 = pow(r200029, r200030);
double r200032 = r200028 * r200031;
double r200033 = -r200032;
double r200034 = 0.016666666666666666;
double r200035 = 5.0;
double r200036 = pow(r200029, r200035);
double r200037 = 2.0;
double r200038 = r200037 * r200029;
double r200039 = fma(r200034, r200036, r200038);
double r200040 = r200033 - r200039;
double r200041 = r200027 * r200040;
return r200041;
}




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 2020034 +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))))