\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\frac{1}{3} \cdot {im}^{3}\right) - \mathsf{fma}\left(\frac{1}{60}, {im}^{5}, 2 \cdot im\right)\right)double f(double re, double im) {
double r302152 = 0.5;
double r302153 = re;
double r302154 = sin(r302153);
double r302155 = r302152 * r302154;
double r302156 = im;
double r302157 = -r302156;
double r302158 = exp(r302157);
double r302159 = exp(r302156);
double r302160 = r302158 - r302159;
double r302161 = r302155 * r302160;
return r302161;
}
double f(double re, double im) {
double r302162 = 0.5;
double r302163 = re;
double r302164 = sin(r302163);
double r302165 = r302162 * r302164;
double r302166 = 0.3333333333333333;
double r302167 = im;
double r302168 = 3.0;
double r302169 = pow(r302167, r302168);
double r302170 = r302166 * r302169;
double r302171 = -r302170;
double r302172 = 0.016666666666666666;
double r302173 = 5.0;
double r302174 = pow(r302167, r302173);
double r302175 = 2.0;
double r302176 = r302175 * r302167;
double r302177 = fma(r302172, r302174, r302176);
double r302178 = r302171 - r302177;
double r302179 = r302165 * r302178;
return r302179;
}




Bits error versus re




Bits error versus im
| Original | 44.1 |
|---|---|
| Target | 0.2 |
| Herbie | 0.7 |
Initial program 44.1
Taylor expanded around 0 0.7
Simplified0.7
Final simplification0.7
herbie shell --seed 2020003 +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))))