\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 r148466 = 0.5;
double r148467 = re;
double r148468 = sin(r148467);
double r148469 = r148466 * r148468;
double r148470 = im;
double r148471 = -r148470;
double r148472 = exp(r148471);
double r148473 = exp(r148470);
double r148474 = r148472 - r148473;
double r148475 = r148469 * r148474;
return r148475;
}
double f(double re, double im) {
double r148476 = 0.5;
double r148477 = re;
double r148478 = sin(r148477);
double r148479 = r148476 * r148478;
double r148480 = -0.3333333333333333;
double r148481 = im;
double r148482 = 3.0;
double r148483 = pow(r148481, r148482);
double r148484 = -2.0;
double r148485 = 5.0;
double r148486 = pow(r148481, r148485);
double r148487 = -0.016666666666666666;
double r148488 = r148486 * r148487;
double r148489 = fma(r148481, r148484, r148488);
double r148490 = fma(r148480, r148483, r148489);
double r148491 = r148479 * r148490;
return r148491;
}




Bits error versus re




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