\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 r197144 = 0.5;
double r197145 = re;
double r197146 = sin(r197145);
double r197147 = r197144 * r197146;
double r197148 = im;
double r197149 = -r197148;
double r197150 = exp(r197149);
double r197151 = exp(r197148);
double r197152 = r197150 - r197151;
double r197153 = r197147 * r197152;
return r197153;
}
double f(double re, double im) {
double r197154 = 0.5;
double r197155 = re;
double r197156 = sin(r197155);
double r197157 = r197154 * r197156;
double r197158 = 0.3333333333333333;
double r197159 = im;
double r197160 = 3.0;
double r197161 = pow(r197159, r197160);
double r197162 = 0.016666666666666666;
double r197163 = 5.0;
double r197164 = pow(r197159, r197163);
double r197165 = 2.0;
double r197166 = r197165 * r197159;
double r197167 = fma(r197162, r197164, r197166);
double r197168 = fma(r197158, r197161, r197167);
double r197169 = -r197168;
double r197170 = r197157 * r197169;
return r197170;
}




Bits error versus re




Bits error versus im
| Original | 43.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.0
Taylor expanded around 0 0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019195 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1.0) (- (* (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))))