\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 r224120 = 0.5;
double r224121 = re;
double r224122 = sin(r224121);
double r224123 = r224120 * r224122;
double r224124 = im;
double r224125 = -r224124;
double r224126 = exp(r224125);
double r224127 = exp(r224124);
double r224128 = r224126 - r224127;
double r224129 = r224123 * r224128;
return r224129;
}
double f(double re, double im) {
double r224130 = 0.5;
double r224131 = re;
double r224132 = sin(r224131);
double r224133 = r224130 * r224132;
double r224134 = -0.3333333333333333;
double r224135 = im;
double r224136 = 3.0;
double r224137 = pow(r224135, r224136);
double r224138 = r224134 * r224137;
double r224139 = r224133 * r224138;
double r224140 = -2.0;
double r224141 = 5.0;
double r224142 = pow(r224135, r224141);
double r224143 = -0.016666666666666666;
double r224144 = r224142 * r224143;
double r224145 = fma(r224135, r224140, r224144);
double r224146 = r224133 * r224145;
double r224147 = r224139 + r224146;
return r224147;
}




Bits error versus re




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