\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 r277423 = 0.5;
double r277424 = re;
double r277425 = cos(r277424);
double r277426 = r277423 * r277425;
double r277427 = 0.0;
double r277428 = im;
double r277429 = r277427 - r277428;
double r277430 = exp(r277429);
double r277431 = exp(r277428);
double r277432 = r277430 - r277431;
double r277433 = r277426 * r277432;
return r277433;
}
double f(double re, double im) {
double r277434 = 0.5;
double r277435 = re;
double r277436 = cos(r277435);
double r277437 = r277434 * r277436;
double r277438 = im;
double r277439 = 3.0;
double r277440 = pow(r277438, r277439);
double r277441 = 0.3333333333333333;
double r277442 = 0.016666666666666666;
double r277443 = 5.0;
double r277444 = pow(r277438, r277443);
double r277445 = r277442 * r277444;
double r277446 = fma(r277440, r277441, r277445);
double r277447 = -r277446;
double r277448 = 2.0;
double r277449 = r277448 * r277438;
double r277450 = r277447 - r277449;
double r277451 = r277437 * r277450;
return r277451;
}




Bits error versus re




Bits error versus im
| Original | 58.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 58.1
Taylor expanded around 0 0.8
Simplified0.8
rmApplied fma-udef0.8
Applied associate--r+0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2020020 +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))))