\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(0.166666666666666657 \cdot \sin re, {im}^{3}, \sin re \cdot \left({im}^{5} \cdot 0.00833333333333333322 + im \cdot 1\right)\right)double f(double re, double im) {
double r239613 = 0.5;
double r239614 = re;
double r239615 = sin(r239614);
double r239616 = r239613 * r239615;
double r239617 = im;
double r239618 = -r239617;
double r239619 = exp(r239618);
double r239620 = exp(r239617);
double r239621 = r239619 - r239620;
double r239622 = r239616 * r239621;
return r239622;
}
double f(double re, double im) {
double r239623 = 0.16666666666666666;
double r239624 = re;
double r239625 = sin(r239624);
double r239626 = r239623 * r239625;
double r239627 = im;
double r239628 = 3.0;
double r239629 = pow(r239627, r239628);
double r239630 = 5.0;
double r239631 = pow(r239627, r239630);
double r239632 = 0.008333333333333333;
double r239633 = r239631 * r239632;
double r239634 = 1.0;
double r239635 = r239627 * r239634;
double r239636 = r239633 + r239635;
double r239637 = r239625 * r239636;
double r239638 = fma(r239626, r239629, r239637);
double r239639 = -r239638;
return r239639;
}




Bits error versus re




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