\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 r275581 = 0.5;
double r275582 = re;
double r275583 = sin(r275582);
double r275584 = r275581 * r275583;
double r275585 = im;
double r275586 = -r275585;
double r275587 = exp(r275586);
double r275588 = exp(r275585);
double r275589 = r275587 - r275588;
double r275590 = r275584 * r275589;
return r275590;
}
double f(double re, double im) {
double r275591 = 0.5;
double r275592 = re;
double r275593 = sin(r275592);
double r275594 = r275591 * r275593;
double r275595 = 0.3333333333333333;
double r275596 = im;
double r275597 = 3.0;
double r275598 = pow(r275596, r275597);
double r275599 = r275595 * r275598;
double r275600 = -r275599;
double r275601 = 0.016666666666666666;
double r275602 = 5.0;
double r275603 = pow(r275596, r275602);
double r275604 = 2.0;
double r275605 = r275604 * r275596;
double r275606 = fma(r275601, r275603, r275605);
double r275607 = r275600 - r275606;
double r275608 = r275594 * r275607;
return r275608;
}




Bits error versus re




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