\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(\sin re, {im}^{5} \cdot 0.008333333333333333, \mathsf{fma}\left(1.0, im \cdot \sin re, \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \sin re\right) \cdot 0.16666666666666666\right)\right)double f(double re, double im) {
double r3431579 = 0.5;
double r3431580 = re;
double r3431581 = sin(r3431580);
double r3431582 = r3431579 * r3431581;
double r3431583 = im;
double r3431584 = -r3431583;
double r3431585 = exp(r3431584);
double r3431586 = exp(r3431583);
double r3431587 = r3431585 - r3431586;
double r3431588 = r3431582 * r3431587;
return r3431588;
}
double f(double re, double im) {
double r3431589 = re;
double r3431590 = sin(r3431589);
double r3431591 = im;
double r3431592 = 5.0;
double r3431593 = pow(r3431591, r3431592);
double r3431594 = 0.008333333333333333;
double r3431595 = r3431593 * r3431594;
double r3431596 = 1.0;
double r3431597 = r3431591 * r3431590;
double r3431598 = r3431591 * r3431591;
double r3431599 = r3431591 * r3431598;
double r3431600 = r3431599 * r3431590;
double r3431601 = 0.16666666666666666;
double r3431602 = r3431600 * r3431601;
double r3431603 = fma(r3431596, r3431597, r3431602);
double r3431604 = fma(r3431590, r3431595, r3431603);
double r3431605 = -r3431604;
return r3431605;
}




Bits error versus re




Bits error versus im
| Original | 44.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 44.0
Taylor expanded around 0 0.8
Simplified0.8
Taylor expanded around inf 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019152 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))