\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(-\mathsf{fma}\left(\frac{1}{3}, {im}^{3}, \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)\right)double f(double re, double im) {
double r202119 = 0.5;
double r202120 = re;
double r202121 = sin(r202120);
double r202122 = r202119 * r202121;
double r202123 = im;
double r202124 = -r202123;
double r202125 = exp(r202124);
double r202126 = exp(r202123);
double r202127 = r202125 - r202126;
double r202128 = r202122 * r202127;
return r202128;
}
double f(double re, double im) {
double r202129 = 0.5;
double r202130 = re;
double r202131 = sin(r202130);
double r202132 = r202129 * r202131;
double r202133 = 0.3333333333333333;
double r202134 = im;
double r202135 = 3.0;
double r202136 = pow(r202134, r202135);
double r202137 = 0.016666666666666666;
double r202138 = 5.0;
double r202139 = pow(r202134, r202138);
double r202140 = 2.0;
double r202141 = r202140 * r202134;
double r202142 = fma(r202137, r202139, r202141);
double r202143 = fma(r202133, r202136, r202142);
double r202144 = -r202143;
double r202145 = r202132 * r202144;
return r202145;
}




Bits error versus re




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