\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(\frac{-1}{3}, {im}^{3}, \mathsf{fma}\left(im, -2, {im}^{5} \cdot \frac{-1}{60}\right)\right)double f(double re, double im) {
double r193799 = 0.5;
double r193800 = re;
double r193801 = sin(r193800);
double r193802 = r193799 * r193801;
double r193803 = im;
double r193804 = -r193803;
double r193805 = exp(r193804);
double r193806 = exp(r193803);
double r193807 = r193805 - r193806;
double r193808 = r193802 * r193807;
return r193808;
}
double f(double re, double im) {
double r193809 = 0.5;
double r193810 = re;
double r193811 = sin(r193810);
double r193812 = r193809 * r193811;
double r193813 = -0.3333333333333333;
double r193814 = im;
double r193815 = 3.0;
double r193816 = pow(r193814, r193815);
double r193817 = -2.0;
double r193818 = 5.0;
double r193819 = pow(r193814, r193818);
double r193820 = -0.016666666666666666;
double r193821 = r193819 * r193820;
double r193822 = fma(r193814, r193817, r193821);
double r193823 = fma(r193813, r193816, r193822);
double r193824 = r193812 * r193823;
return r193824;
}




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
Final simplification0.7
herbie shell --seed 2019326 +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))))