\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(0.5 \cdot \sin re\right) \cdot \left(\left(-\mathsf{fma}\left({im}^{3}, \frac{1}{3}, \frac{1}{60} \cdot {im}^{5}\right)\right) - 2 \cdot im\right)double f(double re, double im) {
double r228047 = 0.5;
double r228048 = re;
double r228049 = sin(r228048);
double r228050 = r228047 * r228049;
double r228051 = im;
double r228052 = -r228051;
double r228053 = exp(r228052);
double r228054 = exp(r228051);
double r228055 = r228053 - r228054;
double r228056 = r228050 * r228055;
return r228056;
}
double f(double re, double im) {
double r228057 = 0.5;
double r228058 = re;
double r228059 = sin(r228058);
double r228060 = r228057 * r228059;
double r228061 = im;
double r228062 = 3.0;
double r228063 = pow(r228061, r228062);
double r228064 = 0.3333333333333333;
double r228065 = 0.016666666666666666;
double r228066 = 5.0;
double r228067 = pow(r228061, r228066);
double r228068 = r228065 * r228067;
double r228069 = fma(r228063, r228064, r228068);
double r228070 = -r228069;
double r228071 = 2.0;
double r228072 = r228071 * r228061;
double r228073 = r228070 - r228072;
double r228074 = r228060 * r228073;
return r228074;
}




Bits error versus re




Bits error versus im
| Original | 43.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 43.1
Taylor expanded around 0 0.8
Simplified0.8
rmApplied fma-udef0.8
Applied associate--r+0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2020039 +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))))