\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 r280512 = 0.5;
double r280513 = re;
double r280514 = sin(r280513);
double r280515 = r280512 * r280514;
double r280516 = im;
double r280517 = -r280516;
double r280518 = exp(r280517);
double r280519 = exp(r280516);
double r280520 = r280518 - r280519;
double r280521 = r280515 * r280520;
return r280521;
}
double f(double re, double im) {
double r280522 = 0.5;
double r280523 = re;
double r280524 = sin(r280523);
double r280525 = r280522 * r280524;
double r280526 = 0.3333333333333333;
double r280527 = im;
double r280528 = 3.0;
double r280529 = pow(r280527, r280528);
double r280530 = 0.016666666666666666;
double r280531 = 5.0;
double r280532 = pow(r280527, r280531);
double r280533 = 2.0;
double r280534 = r280533 * r280527;
double r280535 = fma(r280530, r280532, r280534);
double r280536 = fma(r280526, r280529, r280535);
double r280537 = -r280536;
double r280538 = r280525 * r280537;
return r280538;
}




Bits error versus re




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