\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 r141544 = 0.5;
double r141545 = re;
double r141546 = sin(r141545);
double r141547 = r141544 * r141546;
double r141548 = im;
double r141549 = -r141548;
double r141550 = exp(r141549);
double r141551 = exp(r141548);
double r141552 = r141550 - r141551;
double r141553 = r141547 * r141552;
return r141553;
}
double f(double re, double im) {
double r141554 = 0.5;
double r141555 = re;
double r141556 = sin(r141555);
double r141557 = r141554 * r141556;
double r141558 = -0.3333333333333333;
double r141559 = im;
double r141560 = 3.0;
double r141561 = pow(r141559, r141560);
double r141562 = -2.0;
double r141563 = 5.0;
double r141564 = pow(r141559, r141563);
double r141565 = -0.016666666666666666;
double r141566 = r141564 * r141565;
double r141567 = fma(r141559, r141562, r141566);
double r141568 = fma(r141558, r141561, r141567);
double r141569 = r141557 * r141568;
return r141569;
}




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))))