\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\mathsf{fma}\left(\frac{-1}{60}, {im}^{5}, \mathsf{fma}\left(\frac{1}{3}, im \cdot im, 2\right) \cdot \left(-im\right)\right) \cdot \left(0.5 \cdot \sin re\right)double f(double re, double im) {
double r8354737 = 0.5;
double r8354738 = re;
double r8354739 = sin(r8354738);
double r8354740 = r8354737 * r8354739;
double r8354741 = im;
double r8354742 = -r8354741;
double r8354743 = exp(r8354742);
double r8354744 = exp(r8354741);
double r8354745 = r8354743 - r8354744;
double r8354746 = r8354740 * r8354745;
return r8354746;
}
double f(double re, double im) {
double r8354747 = -0.016666666666666666;
double r8354748 = im;
double r8354749 = 5.0;
double r8354750 = pow(r8354748, r8354749);
double r8354751 = 0.3333333333333333;
double r8354752 = r8354748 * r8354748;
double r8354753 = 2.0;
double r8354754 = fma(r8354751, r8354752, r8354753);
double r8354755 = -r8354748;
double r8354756 = r8354754 * r8354755;
double r8354757 = fma(r8354747, r8354750, r8354756);
double r8354758 = 0.5;
double r8354759 = re;
double r8354760 = sin(r8354759);
double r8354761 = r8354758 * r8354760;
double r8354762 = r8354757 * r8354761;
return r8354762;
}




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 2019163 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))