\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r436311 = 0.5;
double r436312 = re;
double r436313 = sin(r436312);
double r436314 = r436311 * r436313;
double r436315 = im;
double r436316 = -r436315;
double r436317 = exp(r436316);
double r436318 = exp(r436315);
double r436319 = r436317 - r436318;
double r436320 = r436314 * r436319;
return r436320;
}
double f(double re, double im) {
double r436321 = 0.5;
double r436322 = re;
double r436323 = sin(r436322);
double r436324 = r436321 * r436323;
double r436325 = 0.3333333333333333;
double r436326 = im;
double r436327 = 3.0;
double r436328 = pow(r436326, r436327);
double r436329 = r436325 * r436328;
double r436330 = -r436329;
double r436331 = 0.016666666666666666;
double r436332 = 5.0;
double r436333 = pow(r436326, r436332);
double r436334 = 2.0;
double r436335 = r436334 * r436326;
double r436336 = fma(r436331, r436333, r436335);
double r436337 = r436330 - r436336;
double r436338 = r436324 * r436337;
return r436338;
}




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
Final simplification0.8
herbie shell --seed 2020001 +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))))