\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 r210987 = 0.5;
double r210988 = re;
double r210989 = sin(r210988);
double r210990 = r210987 * r210989;
double r210991 = im;
double r210992 = -r210991;
double r210993 = exp(r210992);
double r210994 = exp(r210991);
double r210995 = r210993 - r210994;
double r210996 = r210990 * r210995;
return r210996;
}
double f(double re, double im) {
double r210997 = 0.5;
double r210998 = re;
double r210999 = sin(r210998);
double r211000 = r210997 * r210999;
double r211001 = 0.3333333333333333;
double r211002 = im;
double r211003 = 3.0;
double r211004 = pow(r211002, r211003);
double r211005 = 0.016666666666666666;
double r211006 = 5.0;
double r211007 = pow(r211002, r211006);
double r211008 = 2.0;
double r211009 = r211008 * r211002;
double r211010 = fma(r211005, r211007, r211009);
double r211011 = fma(r211001, r211004, r211010);
double r211012 = -r211011;
double r211013 = r211000 * r211012;
return r211013;
}




Bits error versus re




Bits error versus im
| Original | 44.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
Initial program 44.4
Taylor expanded around 0 0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2019208 +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.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))