\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 r137332 = 0.5;
double r137333 = re;
double r137334 = sin(r137333);
double r137335 = r137332 * r137334;
double r137336 = im;
double r137337 = -r137336;
double r137338 = exp(r137337);
double r137339 = exp(r137336);
double r137340 = r137338 - r137339;
double r137341 = r137335 * r137340;
return r137341;
}
double f(double re, double im) {
double r137342 = 0.5;
double r137343 = re;
double r137344 = sin(r137343);
double r137345 = r137342 * r137344;
double r137346 = -0.3333333333333333;
double r137347 = im;
double r137348 = 3.0;
double r137349 = pow(r137347, r137348);
double r137350 = r137346 * r137349;
double r137351 = r137345 * r137350;
double r137352 = -2.0;
double r137353 = 5.0;
double r137354 = pow(r137347, r137353);
double r137355 = -0.016666666666666666;
double r137356 = r137354 * r137355;
double r137357 = fma(r137347, r137352, r137356);
double r137358 = r137345 * r137357;
double r137359 = r137351 + r137358;
return r137359;
}




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))))