\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, -2, -\mathsf{fma}\left({im}^{3}, \frac{1}{3}, \frac{1}{60} \cdot {im}^{5}\right)\right)double f(double re, double im) {
double r290157 = 0.5;
double r290158 = re;
double r290159 = sin(r290158);
double r290160 = r290157 * r290159;
double r290161 = im;
double r290162 = -r290161;
double r290163 = exp(r290162);
double r290164 = exp(r290161);
double r290165 = r290163 - r290164;
double r290166 = r290160 * r290165;
return r290166;
}
double f(double re, double im) {
double r290167 = 0.5;
double r290168 = re;
double r290169 = sin(r290168);
double r290170 = r290167 * r290169;
double r290171 = im;
double r290172 = -2.0;
double r290173 = 3.0;
double r290174 = pow(r290171, r290173);
double r290175 = 0.3333333333333333;
double r290176 = 0.016666666666666666;
double r290177 = 5.0;
double r290178 = pow(r290171, r290177);
double r290179 = r290176 * r290178;
double r290180 = fma(r290174, r290175, r290179);
double r290181 = -r290180;
double r290182 = fma(r290171, r290172, r290181);
double r290183 = r290170 * r290182;
return r290183;
}




Bits error versus re




Bits error versus im
| Original | 43.7 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
Initial program 43.7
Taylor expanded around 0 0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2020059 +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))))