\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\frac{-1}{3} \cdot {im}^{3}\right) + \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, -2, {im}^{5} \cdot \frac{-1}{60}\right)double f(double re, double im) {
double r212287 = 0.5;
double r212288 = re;
double r212289 = sin(r212288);
double r212290 = r212287 * r212289;
double r212291 = im;
double r212292 = -r212291;
double r212293 = exp(r212292);
double r212294 = exp(r212291);
double r212295 = r212293 - r212294;
double r212296 = r212290 * r212295;
return r212296;
}
double f(double re, double im) {
double r212297 = 0.5;
double r212298 = re;
double r212299 = sin(r212298);
double r212300 = r212297 * r212299;
double r212301 = -0.3333333333333333;
double r212302 = im;
double r212303 = 3.0;
double r212304 = pow(r212302, r212303);
double r212305 = r212301 * r212304;
double r212306 = r212300 * r212305;
double r212307 = -2.0;
double r212308 = 5.0;
double r212309 = pow(r212302, r212308);
double r212310 = -0.016666666666666666;
double r212311 = r212309 * r212310;
double r212312 = fma(r212302, r212307, r212311);
double r212313 = r212300 * r212312;
double r212314 = r212306 + r212313;
return r212314;
}




Bits error versus re




Bits error versus im
| Original | 43.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.5
Taylor expanded around 0 0.8
Simplified0.8
rmApplied fma-udef0.8
Applied distribute-lft-in0.8
Final simplification0.8
herbie shell --seed 2019351 +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))))