\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(-\mathsf{fma}\left(\frac{1}{3}, {im}^{3}, \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)\right)double f(double re, double im) {
double r241802 = 0.5;
double r241803 = re;
double r241804 = sin(r241803);
double r241805 = r241802 * r241804;
double r241806 = im;
double r241807 = -r241806;
double r241808 = exp(r241807);
double r241809 = exp(r241806);
double r241810 = r241808 - r241809;
double r241811 = r241805 * r241810;
return r241811;
}
double f(double re, double im) {
double r241812 = 0.5;
double r241813 = re;
double r241814 = sin(r241813);
double r241815 = r241812 * r241814;
double r241816 = 0.3333333333333333;
double r241817 = im;
double r241818 = 3.0;
double r241819 = pow(r241817, r241818);
double r241820 = 0.016666666666666666;
double r241821 = 5.0;
double r241822 = pow(r241817, r241821);
double r241823 = 2.0;
double r241824 = r241823 * r241817;
double r241825 = fma(r241820, r241822, r241824);
double r241826 = fma(r241816, r241819, r241825);
double r241827 = -r241826;
double r241828 = r241815 * r241827;
return r241828;
}




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))))