\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)0.5 \cdot \left(\sin re \cdot \left(\frac{-1}{3} \cdot {im}^{3}\right)\right) + \left(0.5 \cdot \sin re\right) \cdot \left(-\mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r248213 = 0.5;
double r248214 = re;
double r248215 = sin(r248214);
double r248216 = r248213 * r248215;
double r248217 = im;
double r248218 = -r248217;
double r248219 = exp(r248218);
double r248220 = exp(r248217);
double r248221 = r248219 - r248220;
double r248222 = r248216 * r248221;
return r248222;
}
double f(double re, double im) {
double r248223 = 0.5;
double r248224 = re;
double r248225 = sin(r248224);
double r248226 = -0.3333333333333333;
double r248227 = im;
double r248228 = 3.0;
double r248229 = pow(r248227, r248228);
double r248230 = r248226 * r248229;
double r248231 = r248225 * r248230;
double r248232 = r248223 * r248231;
double r248233 = r248223 * r248225;
double r248234 = 0.016666666666666666;
double r248235 = 5.0;
double r248236 = pow(r248227, r248235);
double r248237 = 2.0;
double r248238 = r248237 * r248227;
double r248239 = fma(r248234, r248236, r248238);
double r248240 = -r248239;
double r248241 = r248233 * r248240;
double r248242 = r248232 + r248241;
return r248242;
}




Bits error versus re




Bits error versus im
| Original | 43.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.8
Taylor expanded around 0 0.8
Simplified0.8
rmApplied add-log-exp0.9
rmApplied sub-neg0.9
Applied distribute-lft-in0.9
Simplified0.8
Final simplification0.8
herbie shell --seed 2020035 +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))))