\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 r255493 = 0.5;
double r255494 = re;
double r255495 = sin(r255494);
double r255496 = r255493 * r255495;
double r255497 = im;
double r255498 = -r255497;
double r255499 = exp(r255498);
double r255500 = exp(r255497);
double r255501 = r255499 - r255500;
double r255502 = r255496 * r255501;
return r255502;
}
double f(double re, double im) {
double r255503 = 0.5;
double r255504 = re;
double r255505 = sin(r255504);
double r255506 = r255503 * r255505;
double r255507 = 0.3333333333333333;
double r255508 = im;
double r255509 = 3.0;
double r255510 = pow(r255508, r255509);
double r255511 = r255507 * r255510;
double r255512 = -r255511;
double r255513 = 0.016666666666666666;
double r255514 = 5.0;
double r255515 = pow(r255508, r255514);
double r255516 = 2.0;
double r255517 = r255516 * r255508;
double r255518 = fma(r255513, r255515, r255517);
double r255519 = r255512 - r255518;
double r255520 = r255506 * r255519;
return r255520;
}




Bits error versus re




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