\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \frac{-1}{3}\right) \cdot \left(0.5 \cdot \sin re\right) + \mathsf{fma}\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \left(im \cdot im\right), \frac{-1}{60}, -2 \cdot im\right) \cdot \left(0.5 \cdot \sin re\right)double f(double re, double im) {
double r7826439 = 0.5;
double r7826440 = re;
double r7826441 = sin(r7826440);
double r7826442 = r7826439 * r7826441;
double r7826443 = im;
double r7826444 = -r7826443;
double r7826445 = exp(r7826444);
double r7826446 = exp(r7826443);
double r7826447 = r7826445 - r7826446;
double r7826448 = r7826442 * r7826447;
return r7826448;
}
double f(double re, double im) {
double r7826449 = im;
double r7826450 = r7826449 * r7826449;
double r7826451 = r7826449 * r7826450;
double r7826452 = -0.3333333333333333;
double r7826453 = r7826451 * r7826452;
double r7826454 = 0.5;
double r7826455 = re;
double r7826456 = sin(r7826455);
double r7826457 = r7826454 * r7826456;
double r7826458 = r7826453 * r7826457;
double r7826459 = r7826451 * r7826450;
double r7826460 = -0.016666666666666666;
double r7826461 = -2.0;
double r7826462 = r7826461 * r7826449;
double r7826463 = fma(r7826459, r7826460, r7826462);
double r7826464 = r7826463 * r7826457;
double r7826465 = r7826458 + r7826464;
return r7826465;
}




Bits error versus re




Bits error versus im
| Original | 43.8 |
|---|---|
| Target | 0.4 |
| Herbie | 0.7 |
Initial program 43.8
Taylor expanded around 0 0.7
Simplified0.7
rmApplied fma-udef0.7
Applied distribute-lft-in0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2019170 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1.0) (- (* (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))))