\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 r296450 = 0.5;
double r296451 = re;
double r296452 = sin(r296451);
double r296453 = r296450 * r296452;
double r296454 = im;
double r296455 = -r296454;
double r296456 = exp(r296455);
double r296457 = exp(r296454);
double r296458 = r296456 - r296457;
double r296459 = r296453 * r296458;
return r296459;
}
double f(double re, double im) {
double r296460 = 0.5;
double r296461 = re;
double r296462 = sin(r296461);
double r296463 = r296460 * r296462;
double r296464 = 0.3333333333333333;
double r296465 = im;
double r296466 = 3.0;
double r296467 = pow(r296465, r296466);
double r296468 = r296464 * r296467;
double r296469 = -r296468;
double r296470 = 0.016666666666666666;
double r296471 = 5.0;
double r296472 = pow(r296465, r296471);
double r296473 = 2.0;
double r296474 = r296473 * r296465;
double r296475 = fma(r296470, r296472, r296474);
double r296476 = r296469 - r296475;
double r296477 = r296463 * r296476;
return r296477;
}




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