\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\left(\frac{-1}{3} \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \left(0.5 \cdot \sin re\right) + \left(0.5 \cdot \sin re\right) \cdot \left(\left(\left(im \cdot im\right) \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) \cdot \frac{-1}{60} - \left(im + im\right)\right)double f(double re, double im) {
double r8290547 = 0.5;
double r8290548 = re;
double r8290549 = sin(r8290548);
double r8290550 = r8290547 * r8290549;
double r8290551 = im;
double r8290552 = -r8290551;
double r8290553 = exp(r8290552);
double r8290554 = exp(r8290551);
double r8290555 = r8290553 - r8290554;
double r8290556 = r8290550 * r8290555;
return r8290556;
}
double f(double re, double im) {
double r8290557 = -0.3333333333333333;
double r8290558 = im;
double r8290559 = r8290558 * r8290558;
double r8290560 = r8290558 * r8290559;
double r8290561 = r8290557 * r8290560;
double r8290562 = 0.5;
double r8290563 = re;
double r8290564 = sin(r8290563);
double r8290565 = r8290562 * r8290564;
double r8290566 = r8290561 * r8290565;
double r8290567 = r8290559 * r8290560;
double r8290568 = -0.016666666666666666;
double r8290569 = r8290567 * r8290568;
double r8290570 = r8290558 + r8290558;
double r8290571 = r8290569 - r8290570;
double r8290572 = r8290565 * r8290571;
double r8290573 = r8290566 + r8290572;
return r8290573;
}




Bits error versus re




Bits error versus im
Results
| Original | 44.0 |
|---|---|
| Target | 0.3 |
| Herbie | 0.8 |
Initial program 44.0
Taylor expanded around 0 0.8
Simplified0.8
rmApplied sub-neg0.8
Applied distribute-lft-in0.8
Simplified0.8
Final simplification0.8
herbie shell --seed 2019152 +o rules:numerics
(FPCore (re im)
:name "math.cos on complex, imaginary part"
:herbie-target
(if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))
(* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))