\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\sqrt[3]{-\frac{1}{3} \cdot {im}^{3}} \cdot \sqrt[3]{-\frac{1}{3} \cdot {im}^{3}}, \sqrt[3]{-\frac{1}{3} \cdot {im}^{3}}, -\mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r211667 = 0.5;
double r211668 = re;
double r211669 = sin(r211668);
double r211670 = r211667 * r211669;
double r211671 = im;
double r211672 = -r211671;
double r211673 = exp(r211672);
double r211674 = exp(r211671);
double r211675 = r211673 - r211674;
double r211676 = r211670 * r211675;
return r211676;
}
double f(double re, double im) {
double r211677 = 0.5;
double r211678 = re;
double r211679 = sin(r211678);
double r211680 = r211677 * r211679;
double r211681 = 0.3333333333333333;
double r211682 = im;
double r211683 = 3.0;
double r211684 = pow(r211682, r211683);
double r211685 = r211681 * r211684;
double r211686 = -r211685;
double r211687 = cbrt(r211686);
double r211688 = r211687 * r211687;
double r211689 = 0.016666666666666666;
double r211690 = 5.0;
double r211691 = pow(r211682, r211690);
double r211692 = 2.0;
double r211693 = r211692 * r211682;
double r211694 = fma(r211689, r211691, r211693);
double r211695 = -r211694;
double r211696 = fma(r211688, r211687, r211695);
double r211697 = r211680 * r211696;
return r211697;
}




Bits error versus re




Bits error versus im
| Original | 43.4 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
Initial program 43.4
Taylor expanded around 0 0.7
Simplified0.7
rmApplied add-cube-cbrt0.7
Applied fma-neg0.7
Final simplification0.7
herbie shell --seed 2019344 +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))))