\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left(0.166666666666666657 \cdot \sin re, {im}^{3}, \sin re \cdot \left(1 \cdot im + 0.00833333333333333322 \cdot {im}^{5}\right)\right)double f(double re, double im) {
double r252085 = 0.5;
double r252086 = re;
double r252087 = sin(r252086);
double r252088 = r252085 * r252087;
double r252089 = im;
double r252090 = -r252089;
double r252091 = exp(r252090);
double r252092 = exp(r252089);
double r252093 = r252091 - r252092;
double r252094 = r252088 * r252093;
return r252094;
}
double f(double re, double im) {
double r252095 = 0.16666666666666666;
double r252096 = re;
double r252097 = sin(r252096);
double r252098 = r252095 * r252097;
double r252099 = im;
double r252100 = 3.0;
double r252101 = pow(r252099, r252100);
double r252102 = 1.0;
double r252103 = r252102 * r252099;
double r252104 = 0.008333333333333333;
double r252105 = 5.0;
double r252106 = pow(r252099, r252105);
double r252107 = r252104 * r252106;
double r252108 = r252103 + r252107;
double r252109 = r252097 * r252108;
double r252110 = fma(r252098, r252101, r252109);
double r252111 = -r252110;
return r252111;
}




Bits error versus re




Bits error versus im
| Original | 43.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.7 |
Initial program 43.3
Taylor expanded around 0 0.7
Simplified0.7
Taylor expanded around inf 0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2020046 +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))))