\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\frac{-1}{3}, {im}^{3}, \mathsf{fma}\left(im, -2, {im}^{5} \cdot \frac{-1}{60}\right)\right)double f(double re, double im) {
double r141580 = 0.5;
double r141581 = re;
double r141582 = sin(r141581);
double r141583 = r141580 * r141582;
double r141584 = im;
double r141585 = -r141584;
double r141586 = exp(r141585);
double r141587 = exp(r141584);
double r141588 = r141586 - r141587;
double r141589 = r141583 * r141588;
return r141589;
}
double f(double re, double im) {
double r141590 = 0.5;
double r141591 = re;
double r141592 = sin(r141591);
double r141593 = r141590 * r141592;
double r141594 = -0.3333333333333333;
double r141595 = im;
double r141596 = 3.0;
double r141597 = pow(r141595, r141596);
double r141598 = -2.0;
double r141599 = 5.0;
double r141600 = pow(r141595, r141599);
double r141601 = -0.016666666666666666;
double r141602 = r141600 * r141601;
double r141603 = fma(r141595, r141598, r141602);
double r141604 = fma(r141594, r141597, r141603);
double r141605 = r141593 * r141604;
return r141605;
}




Bits error versus re




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