\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(0.008333333333333333217685101601546193705872 \cdot \sin re, {im}^{5}, \sin re \cdot \left(1 \cdot im + 0.1666666666666666574148081281236954964697 \cdot {im}^{3}\right)\right)double f(double re, double im) {
double r139455 = 0.5;
double r139456 = re;
double r139457 = sin(r139456);
double r139458 = r139455 * r139457;
double r139459 = im;
double r139460 = -r139459;
double r139461 = exp(r139460);
double r139462 = exp(r139459);
double r139463 = r139461 - r139462;
double r139464 = r139458 * r139463;
return r139464;
}
double f(double re, double im) {
double r139465 = 0.008333333333333333;
double r139466 = re;
double r139467 = sin(r139466);
double r139468 = r139465 * r139467;
double r139469 = im;
double r139470 = 5.0;
double r139471 = pow(r139469, r139470);
double r139472 = 1.0;
double r139473 = r139472 * r139469;
double r139474 = 0.16666666666666666;
double r139475 = 3.0;
double r139476 = pow(r139469, r139475);
double r139477 = r139474 * r139476;
double r139478 = r139473 + r139477;
double r139479 = r139467 * r139478;
double r139480 = fma(r139468, r139471, r139479);
double r139481 = -r139480;
return r139481;
}




Bits error versus re




Bits error versus im
| Original | 44.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
Initial program 44.2
Taylor expanded around 0 0.7
Simplified0.7
Taylor expanded around inf 0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2019212 +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.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))