\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)-\mathsf{fma}\left({im}^{5}, \sin re \cdot 0.008333333333333333, \sin re \cdot \left(\left(im \cdot \left(im \cdot im\right)\right) \cdot 0.16666666666666666 + 1.0 \cdot im\right)\right)double f(double re, double im) {
double r10295641 = 0.5;
double r10295642 = re;
double r10295643 = sin(r10295642);
double r10295644 = r10295641 * r10295643;
double r10295645 = im;
double r10295646 = -r10295645;
double r10295647 = exp(r10295646);
double r10295648 = exp(r10295645);
double r10295649 = r10295647 - r10295648;
double r10295650 = r10295644 * r10295649;
return r10295650;
}
double f(double re, double im) {
double r10295651 = im;
double r10295652 = 5.0;
double r10295653 = pow(r10295651, r10295652);
double r10295654 = re;
double r10295655 = sin(r10295654);
double r10295656 = 0.008333333333333333;
double r10295657 = r10295655 * r10295656;
double r10295658 = r10295651 * r10295651;
double r10295659 = r10295651 * r10295658;
double r10295660 = 0.16666666666666666;
double r10295661 = r10295659 * r10295660;
double r10295662 = 1.0;
double r10295663 = r10295662 * r10295651;
double r10295664 = r10295661 + r10295663;
double r10295665 = r10295655 * r10295664;
double r10295666 = fma(r10295653, r10295657, r10295665);
double r10295667 = -r10295666;
return r10295667;
}




Bits error versus re




Bits error versus im
| Original | 43.8 |
|---|---|
| Target | 0.3 |
| Herbie | 0.9 |
Initial program 43.8
Taylor expanded around 0 0.9
Simplified0.9
Taylor expanded around inf 0.9
Simplified0.9
Final simplification0.9
herbie shell --seed 2019168 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))