\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\frac{-1}{3} \cdot {im}^{3}\right) + \left(0.5 \cdot \sin re\right) \cdot \mathsf{fma}\left(im, -2, {im}^{5} \cdot \frac{-1}{60}\right)double f(double re, double im) {
double r219086 = 0.5;
double r219087 = re;
double r219088 = sin(r219087);
double r219089 = r219086 * r219088;
double r219090 = im;
double r219091 = -r219090;
double r219092 = exp(r219091);
double r219093 = exp(r219090);
double r219094 = r219092 - r219093;
double r219095 = r219089 * r219094;
return r219095;
}
double f(double re, double im) {
double r219096 = 0.5;
double r219097 = re;
double r219098 = sin(r219097);
double r219099 = r219096 * r219098;
double r219100 = -0.3333333333333333;
double r219101 = im;
double r219102 = 3.0;
double r219103 = pow(r219101, r219102);
double r219104 = r219100 * r219103;
double r219105 = r219099 * r219104;
double r219106 = -2.0;
double r219107 = 5.0;
double r219108 = pow(r219101, r219107);
double r219109 = -0.016666666666666666;
double r219110 = r219108 * r219109;
double r219111 = fma(r219101, r219106, r219110);
double r219112 = r219099 * r219111;
double r219113 = r219105 + r219112;
return r219113;
}




Bits error versus re




Bits error versus im
| Original | 43.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.8 |
Initial program 43.4
Taylor expanded around 0 0.8
Simplified0.8
rmApplied fma-udef0.8
Applied distribute-lft-in0.8
Final simplification0.8
herbie shell --seed 2019304 +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))))