\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r241156 = 0.5;
double r241157 = re;
double r241158 = sin(r241157);
double r241159 = r241156 * r241158;
double r241160 = im;
double r241161 = -r241160;
double r241162 = exp(r241161);
double r241163 = exp(r241160);
double r241164 = r241162 - r241163;
double r241165 = r241159 * r241164;
return r241165;
}
double f(double re, double im) {
double r241166 = 0.5;
double r241167 = re;
double r241168 = sin(r241167);
double r241169 = r241166 * r241168;
double r241170 = 0.3333333333333333;
double r241171 = im;
double r241172 = 3.0;
double r241173 = pow(r241171, r241172);
double r241174 = r241170 * r241173;
double r241175 = -r241174;
double r241176 = 0.016666666666666666;
double r241177 = 5.0;
double r241178 = pow(r241171, r241177);
double r241179 = 2.0;
double r241180 = r241179 * r241171;
double r241181 = fma(r241176, r241178, r241180);
double r241182 = r241175 - r241181;
double r241183 = r241169 * r241182;
return r241183;
}




Bits error versus re




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