\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left({im}^{5}, \sin re \cdot 0.008333333333333333217685101601546193705872, \sin re \cdot \left({im}^{3} \cdot 0.1666666666666666574148081281236954964697 + im \cdot 1\right)\right)double f(double re, double im) {
double r145772 = 0.5;
double r145773 = re;
double r145774 = sin(r145773);
double r145775 = r145772 * r145774;
double r145776 = im;
double r145777 = -r145776;
double r145778 = exp(r145777);
double r145779 = exp(r145776);
double r145780 = r145778 - r145779;
double r145781 = r145775 * r145780;
return r145781;
}
double f(double re, double im) {
double r145782 = im;
double r145783 = 5.0;
double r145784 = pow(r145782, r145783);
double r145785 = re;
double r145786 = sin(r145785);
double r145787 = 0.008333333333333333;
double r145788 = r145786 * r145787;
double r145789 = 3.0;
double r145790 = pow(r145782, r145789);
double r145791 = 0.16666666666666666;
double r145792 = r145790 * r145791;
double r145793 = 1.0;
double r145794 = r145782 * r145793;
double r145795 = r145792 + r145794;
double r145796 = r145786 * r145795;
double r145797 = fma(r145784, r145788, r145796);
double r145798 = -r145797;
return r145798;
}




Bits error versus re




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