\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(\frac{-1}{3}, {im}^{3}, \mathsf{fma}\left(im, -2, {im}^{5} \cdot \frac{-1}{60}\right)\right)double f(double re, double im) {
double r119024 = 0.5;
double r119025 = re;
double r119026 = sin(r119025);
double r119027 = r119024 * r119026;
double r119028 = im;
double r119029 = -r119028;
double r119030 = exp(r119029);
double r119031 = exp(r119028);
double r119032 = r119030 - r119031;
double r119033 = r119027 * r119032;
return r119033;
}
double f(double re, double im) {
double r119034 = 0.5;
double r119035 = re;
double r119036 = sin(r119035);
double r119037 = r119034 * r119036;
double r119038 = -0.3333333333333333;
double r119039 = im;
double r119040 = 3.0;
double r119041 = pow(r119039, r119040);
double r119042 = -2.0;
double r119043 = 5.0;
double r119044 = pow(r119039, r119043);
double r119045 = -0.016666666666666666;
double r119046 = r119044 * r119045;
double r119047 = fma(r119039, r119042, r119046);
double r119048 = fma(r119038, r119041, r119047);
double r119049 = r119037 * r119048;
return r119049;
}




Bits error versus re




Bits error versus im
| Original | 43.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.2
Taylor expanded around 0 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019303 +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))))