\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\left(0.5 \cdot \cos re\right) \cdot \left(\left(-\mathsf{fma}\left({im}^{3}, \frac{1}{3}, \frac{1}{60} \cdot {im}^{5}\right)\right) - 2 \cdot im\right)double f(double re, double im) {
double r212872 = 0.5;
double r212873 = re;
double r212874 = cos(r212873);
double r212875 = r212872 * r212874;
double r212876 = 0.0;
double r212877 = im;
double r212878 = r212876 - r212877;
double r212879 = exp(r212878);
double r212880 = exp(r212877);
double r212881 = r212879 - r212880;
double r212882 = r212875 * r212881;
return r212882;
}
double f(double re, double im) {
double r212883 = 0.5;
double r212884 = re;
double r212885 = cos(r212884);
double r212886 = r212883 * r212885;
double r212887 = im;
double r212888 = 3.0;
double r212889 = pow(r212887, r212888);
double r212890 = 0.3333333333333333;
double r212891 = 0.016666666666666666;
double r212892 = 5.0;
double r212893 = pow(r212887, r212892);
double r212894 = r212891 * r212893;
double r212895 = fma(r212889, r212890, r212894);
double r212896 = -r212895;
double r212897 = 2.0;
double r212898 = r212897 * r212887;
double r212899 = r212896 - r212898;
double r212900 = r212886 * r212899;
return r212900;
}




Bits error versus re




Bits error versus im
| Original | 58.1 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
Initial program 58.1
Taylor expanded around 0 0.7
Simplified0.7
rmApplied fma-udef0.7
Applied associate--r+0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2020046 +o rules:numerics
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))