\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(im \cdot \left(im \cdot im\right), \sin re \cdot 0.16666666666666666, \sin re \cdot \left(1.0 \cdot im + {im}^{5} \cdot 0.008333333333333333\right)\right)double f(double re, double im) {
double r7860710 = 0.5;
double r7860711 = re;
double r7860712 = sin(r7860711);
double r7860713 = r7860710 * r7860712;
double r7860714 = im;
double r7860715 = -r7860714;
double r7860716 = exp(r7860715);
double r7860717 = exp(r7860714);
double r7860718 = r7860716 - r7860717;
double r7860719 = r7860713 * r7860718;
return r7860719;
}
double f(double re, double im) {
double r7860720 = im;
double r7860721 = r7860720 * r7860720;
double r7860722 = r7860720 * r7860721;
double r7860723 = re;
double r7860724 = sin(r7860723);
double r7860725 = 0.16666666666666666;
double r7860726 = r7860724 * r7860725;
double r7860727 = 1.0;
double r7860728 = r7860727 * r7860720;
double r7860729 = 5.0;
double r7860730 = pow(r7860720, r7860729);
double r7860731 = 0.008333333333333333;
double r7860732 = r7860730 * r7860731;
double r7860733 = r7860728 + r7860732;
double r7860734 = r7860724 * r7860733;
double r7860735 = fma(r7860722, r7860726, r7860734);
double r7860736 = -r7860735;
return r7860736;
}




Bits error versus re




Bits error versus im
| Original | 43.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.8 |
Initial program 43.5
Taylor expanded around 0 0.8
Simplified0.8
Taylor expanded around inf 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019162 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))