\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(-\mathsf{fma}\left(\frac{1}{3}, {im}^{3}, \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)\right)double f(double re, double im) {
double r632476 = 0.5;
double r632477 = re;
double r632478 = sin(r632477);
double r632479 = r632476 * r632478;
double r632480 = im;
double r632481 = -r632480;
double r632482 = exp(r632481);
double r632483 = exp(r632480);
double r632484 = r632482 - r632483;
double r632485 = r632479 * r632484;
return r632485;
}
double f(double re, double im) {
double r632486 = 0.5;
double r632487 = re;
double r632488 = sin(r632487);
double r632489 = r632486 * r632488;
double r632490 = 0.3333333333333333;
double r632491 = im;
double r632492 = 3.0;
double r632493 = pow(r632491, r632492);
double r632494 = 0.016666666666666666;
double r632495 = 5.0;
double r632496 = pow(r632491, r632495);
double r632497 = 2.0;
double r632498 = r632497 * r632491;
double r632499 = fma(r632494, r632496, r632498);
double r632500 = fma(r632490, r632493, r632499);
double r632501 = -r632500;
double r632502 = r632489 * r632501;
return r632502;
}




Bits error versus re




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