\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(\left(\mathsf{fma}\left({im}^{5}, \frac{-1}{60}, {im}^{3} \cdot \frac{-1}{3}\right) - 2 \cdot im\right) \cdot 0.5\right) \cdot \sin redouble f(double re, double im) {
double r110470 = 0.5;
double r110471 = re;
double r110472 = sin(r110471);
double r110473 = r110470 * r110472;
double r110474 = im;
double r110475 = -r110474;
double r110476 = exp(r110475);
double r110477 = exp(r110474);
double r110478 = r110476 - r110477;
double r110479 = r110473 * r110478;
return r110479;
}
double f(double re, double im) {
double r110480 = im;
double r110481 = 5.0;
double r110482 = pow(r110480, r110481);
double r110483 = -0.016666666666666666;
double r110484 = 3.0;
double r110485 = pow(r110480, r110484);
double r110486 = -0.3333333333333333;
double r110487 = r110485 * r110486;
double r110488 = fma(r110482, r110483, r110487);
double r110489 = 2.0;
double r110490 = r110489 * r110480;
double r110491 = r110488 - r110490;
double r110492 = 0.5;
double r110493 = r110491 * r110492;
double r110494 = re;
double r110495 = sin(r110494);
double r110496 = r110493 * r110495;
return r110496;
}




Bits error versus re




Bits error versus im
| Original | 43.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.7
Simplified43.7
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 2019194 +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))))