\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 r278455 = 0.5;
double r278456 = re;
double r278457 = sin(r278456);
double r278458 = r278455 * r278457;
double r278459 = im;
double r278460 = -r278459;
double r278461 = exp(r278460);
double r278462 = exp(r278459);
double r278463 = r278461 - r278462;
double r278464 = r278458 * r278463;
return r278464;
}
double f(double re, double im) {
double r278465 = 0.5;
double r278466 = re;
double r278467 = sin(r278466);
double r278468 = r278465 * r278467;
double r278469 = 0.3333333333333333;
double r278470 = im;
double r278471 = 3.0;
double r278472 = pow(r278470, r278471);
double r278473 = r278469 * r278472;
double r278474 = -r278473;
double r278475 = 0.016666666666666666;
double r278476 = 5.0;
double r278477 = pow(r278470, r278476);
double r278478 = 2.0;
double r278479 = r278478 * r278470;
double r278480 = fma(r278475, r278477, r278479);
double r278481 = r278474 - r278480;
double r278482 = r278468 * r278481;
return r278482;
}




Bits error versus re




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