\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(\frac{-1}{3} \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.5 \cdot \sin re\right) + \mathsf{fma}\left(im \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot im\right)\right), \frac{-1}{60}, im \cdot -2\right) \cdot \left(0.5 \cdot \sin re\right)double f(double re, double im) {
double r10589975 = 0.5;
double r10589976 = re;
double r10589977 = sin(r10589976);
double r10589978 = r10589975 * r10589977;
double r10589979 = im;
double r10589980 = -r10589979;
double r10589981 = exp(r10589980);
double r10589982 = exp(r10589979);
double r10589983 = r10589981 - r10589982;
double r10589984 = r10589978 * r10589983;
return r10589984;
}
double f(double re, double im) {
double r10589985 = -0.3333333333333333;
double r10589986 = im;
double r10589987 = r10589986 * r10589986;
double r10589988 = r10589986 * r10589987;
double r10589989 = r10589985 * r10589988;
double r10589990 = 0.5;
double r10589991 = re;
double r10589992 = sin(r10589991);
double r10589993 = r10589990 * r10589992;
double r10589994 = r10589989 * r10589993;
double r10589995 = r10589987 * r10589987;
double r10589996 = r10589986 * r10589995;
double r10589997 = -0.016666666666666666;
double r10589998 = -2.0;
double r10589999 = r10589986 * r10589998;
double r10590000 = fma(r10589996, r10589997, r10589999);
double r10590001 = r10590000 * r10589993;
double r10590002 = r10589994 + r10590001;
return r10590002;
}




Bits error versus re




Bits error versus im
| Original | 43.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.9 |
Initial program 43.5
Taylor expanded around 0 0.9
Simplified0.9
rmApplied sub-neg0.9
Applied distribute-lft-in0.9
Simplified0.9
Final simplification0.9
herbie shell --seed 2019143 +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))))