\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)0.5 \cdot \left(-\mathsf{fma}\left(\frac{1}{3}, {im}^{3}, \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right) \cdot \cos re\right)double f(double re, double im) {
double r290231 = 0.5;
double r290232 = re;
double r290233 = cos(r290232);
double r290234 = r290231 * r290233;
double r290235 = 0.0;
double r290236 = im;
double r290237 = r290235 - r290236;
double r290238 = exp(r290237);
double r290239 = exp(r290236);
double r290240 = r290238 - r290239;
double r290241 = r290234 * r290240;
return r290241;
}
double f(double re, double im) {
double r290242 = 0.5;
double r290243 = 0.3333333333333333;
double r290244 = im;
double r290245 = 3.0;
double r290246 = pow(r290244, r290245);
double r290247 = 0.016666666666666666;
double r290248 = 5.0;
double r290249 = pow(r290244, r290248);
double r290250 = 2.0;
double r290251 = r290250 * r290244;
double r290252 = fma(r290247, r290249, r290251);
double r290253 = fma(r290243, r290246, r290252);
double r290254 = re;
double r290255 = cos(r290254);
double r290256 = r290253 * r290255;
double r290257 = -r290256;
double r290258 = r290242 * r290257;
return r290258;
}




Bits error versus re




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