\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(\sin re, {im}^{5} \cdot 0.008333333333333333217685101601546193705872, \mathsf{fma}\left(1, im \cdot \sin re, \left(0.1666666666666666574148081281236954964697 \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot \sin re\right)\right)\right)double f(double re, double im) {
double r7672790 = 0.5;
double r7672791 = re;
double r7672792 = sin(r7672791);
double r7672793 = r7672790 * r7672792;
double r7672794 = im;
double r7672795 = -r7672794;
double r7672796 = exp(r7672795);
double r7672797 = exp(r7672794);
double r7672798 = r7672796 - r7672797;
double r7672799 = r7672793 * r7672798;
return r7672799;
}
double f(double re, double im) {
double r7672800 = re;
double r7672801 = sin(r7672800);
double r7672802 = im;
double r7672803 = 5.0;
double r7672804 = pow(r7672802, r7672803);
double r7672805 = 0.008333333333333333;
double r7672806 = r7672804 * r7672805;
double r7672807 = 1.0;
double r7672808 = r7672802 * r7672801;
double r7672809 = 0.16666666666666666;
double r7672810 = r7672802 * r7672802;
double r7672811 = r7672809 * r7672810;
double r7672812 = r7672811 * r7672808;
double r7672813 = fma(r7672807, r7672808, r7672812);
double r7672814 = fma(r7672801, r7672806, r7672813);
double r7672815 = -r7672814;
return r7672815;
}




Bits error versus re




Bits error versus im
| Original | 43.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.9 |
Initial program 43.8
Taylor expanded around 0 0.9
Simplified0.9
Taylor expanded around inf 0.9
Simplified0.9
Final simplification0.9
herbie shell --seed 2019168 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1.0) (- (* (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))))