\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\begin{array}{l}
t_0 := e^{-im} - e^{im}\\
t_1 := 0.5 \cdot \cos re\\
\mathbf{if}\;t_0 \leq -0.1294210565445304 \lor \neg \left(t_0 \leq 1.558032003412535 \cdot 10^{-8}\right):\\
\;\;\;\;t_0 \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \left({im}^{3} \cdot -0.3333333333333333 + im \cdot -2\right)\\
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(FPCore (re im)
:precision binary64
(let* ((t_0 (- (exp (- im)) (exp im))) (t_1 (* 0.5 (cos re))))
(if (or (<= t_0 -0.1294210565445304) (not (<= t_0 1.558032003412535e-8)))
(* t_0 t_1)
(* t_1 (+ (* (pow im 3.0) -0.3333333333333333) (* im -2.0))))))double code(double re, double im) {
return (0.5 * cos(re)) * (exp(0.0 - im) - exp(im));
}
double code(double re, double im) {
double t_0 = exp(-im) - exp(im);
double t_1 = 0.5 * cos(re);
double tmp;
if ((t_0 <= -0.1294210565445304) || !(t_0 <= 1.558032003412535e-8)) {
tmp = t_0 * t_1;
} else {
tmp = t_1 * ((pow(im, 3.0) * -0.3333333333333333) + (im * -2.0));
}
return tmp;
}




Bits error versus re




Bits error versus im
Results
| Original | 28.9 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
if (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < -0.1294210565445304 or 1.558032003e-8 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) Initial program 0.1
if -0.1294210565445304 < (-.f64 (exp.f64 (-.f64 0 im)) (exp.f64 im)) < 1.558032003e-8Initial program 59.1
Taylor expanded in im around 0 0.2
Final simplification0.1
herbie shell --seed 2022067
(FPCore (re im)
:name "math.sin on complex, imaginary part"
:precision binary64
:herbie-target
(if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))
(* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))