\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 r128681 = 0.5;
double r128682 = re;
double r128683 = sin(r128682);
double r128684 = r128681 * r128683;
double r128685 = im;
double r128686 = -r128685;
double r128687 = exp(r128686);
double r128688 = exp(r128685);
double r128689 = r128687 - r128688;
double r128690 = r128684 * r128689;
return r128690;
}
double f(double re, double im) {
double r128691 = 0.5;
double r128692 = re;
double r128693 = sin(r128692);
double r128694 = r128691 * r128693;
double r128695 = -0.3333333333333333;
double r128696 = im;
double r128697 = 3.0;
double r128698 = pow(r128696, r128697);
double r128699 = -2.0;
double r128700 = 5.0;
double r128701 = pow(r128696, r128700);
double r128702 = -0.016666666666666666;
double r128703 = r128701 * r128702;
double r128704 = fma(r128696, r128699, r128703);
double r128705 = fma(r128695, r128698, r128704);
double r128706 = r128694 * r128705;
return r128706;
}




Bits error versus re




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