\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 r169294 = 0.5;
double r169295 = re;
double r169296 = sin(r169295);
double r169297 = r169294 * r169296;
double r169298 = im;
double r169299 = -r169298;
double r169300 = exp(r169299);
double r169301 = exp(r169298);
double r169302 = r169300 - r169301;
double r169303 = r169297 * r169302;
return r169303;
}
double f(double re, double im) {
double r169304 = 0.5;
double r169305 = re;
double r169306 = sin(r169305);
double r169307 = r169304 * r169306;
double r169308 = -0.3333333333333333;
double r169309 = im;
double r169310 = 3.0;
double r169311 = pow(r169309, r169310);
double r169312 = r169308 * r169311;
double r169313 = r169307 * r169312;
double r169314 = -2.0;
double r169315 = 5.0;
double r169316 = pow(r169309, r169315);
double r169317 = -0.016666666666666666;
double r169318 = r169316 * r169317;
double r169319 = fma(r169309, r169314, r169318);
double r169320 = r169307 * r169319;
double r169321 = r169313 + r169320;
return r169321;
}




Bits error versus re




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