\left(0.5 \cdot \cos re\right) \cdot \left(e^{-im} + e^{im}\right)
\begin{array}{l}
t_0 := 0.5 \cdot \cos re\\
\mathsf{fma}\left(e^{-im}, t_0, t_0 \cdot e^{im}\right)
\end{array}
(FPCore (re im) :precision binary64 (* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))
(FPCore (re im) :precision binary64 (let* ((t_0 (* 0.5 (cos re)))) (fma (exp (- im)) t_0 (* t_0 (exp im)))))
double code(double re, double im) {
return (0.5 * cos(re)) * (exp(-im) + exp(im));
}
double code(double re, double im) {
double t_0 = 0.5 * cos(re);
return fma(exp(-im), t_0, (t_0 * exp(im)));
}



Bits error versus re



Bits error versus im
Initial program 0.0
rmApplied distribute-rgt-in_binary640.0
Applied fma-def_binary640.0
Final simplification0.0
herbie shell --seed 2021211
(FPCore (re im)
:name "math.cos on complex, real part"
:precision binary64
(* (* 0.5 (cos re)) (+ (exp (- im)) (exp im))))