\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\left(0.5 \cdot \cos re\right) \cdot \left(\left(-\mathsf{fma}\left({im}^{3}, \frac{1}{3}, \frac{1}{60} \cdot {im}^{5}\right)\right) - 2 \cdot im\right)double f(double re, double im) {
double r307348 = 0.5;
double r307349 = re;
double r307350 = cos(r307349);
double r307351 = r307348 * r307350;
double r307352 = 0.0;
double r307353 = im;
double r307354 = r307352 - r307353;
double r307355 = exp(r307354);
double r307356 = exp(r307353);
double r307357 = r307355 - r307356;
double r307358 = r307351 * r307357;
return r307358;
}
double f(double re, double im) {
double r307359 = 0.5;
double r307360 = re;
double r307361 = cos(r307360);
double r307362 = r307359 * r307361;
double r307363 = im;
double r307364 = 3.0;
double r307365 = pow(r307363, r307364);
double r307366 = 0.3333333333333333;
double r307367 = 0.016666666666666666;
double r307368 = 5.0;
double r307369 = pow(r307363, r307368);
double r307370 = r307367 * r307369;
double r307371 = fma(r307365, r307366, r307370);
double r307372 = -r307371;
double r307373 = 2.0;
double r307374 = r307373 * r307363;
double r307375 = r307372 - r307374;
double r307376 = r307362 * r307375;
return r307376;
}




Bits error versus re




Bits error versus im
| Original | 58.2 |
|---|---|
| Target | 0.2 |
| Herbie | 0.6 |
Initial program 58.2
Taylor expanded around 0 0.6
Simplified0.6
rmApplied fma-udef0.6
Applied associate--r+0.6
Simplified0.6
Final simplification0.6
herbie shell --seed 2019352 +o rules:numerics
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))