\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r379723 = 0.5;
double r379724 = re;
double r379725 = sin(r379724);
double r379726 = r379723 * r379725;
double r379727 = im;
double r379728 = -r379727;
double r379729 = exp(r379728);
double r379730 = exp(r379727);
double r379731 = r379729 - r379730;
double r379732 = r379726 * r379731;
return r379732;
}
double f(double re, double im) {
double r379733 = 0.5;
double r379734 = re;
double r379735 = sin(r379734);
double r379736 = r379733 * r379735;
double r379737 = 0.3333333333333333;
double r379738 = im;
double r379739 = 3.0;
double r379740 = pow(r379738, r379739);
double r379741 = r379737 * r379740;
double r379742 = -r379741;
double r379743 = 0.016666666666666666;
double r379744 = 5.0;
double r379745 = pow(r379738, r379744);
double r379746 = 2.0;
double r379747 = r379746 * r379738;
double r379748 = fma(r379743, r379745, r379747);
double r379749 = r379742 - r379748;
double r379750 = r379736 * r379749;
return r379750;
}




Bits error versus re




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