Average Error: 0.1 → 0.1
Time: 6.3s
Precision: binary64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
\[\begin{array}{l} t_0 := 0.5 \cdot \sin re\\ \mathsf{fma}\left(e^{-im}, t_0, t_0 \cdot e^{im}\right) \end{array} \]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right)
\begin{array}{l}
t_0 := 0.5 \cdot \sin re\\
\mathsf{fma}\left(e^{-im}, t_0, t_0 \cdot e^{im}\right)
\end{array}
(FPCore (re im)
 :precision binary64
 (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))
(FPCore (re im)
 :precision binary64
 (let* ((t_0 (* 0.5 (sin re)))) (fma (exp (- im)) t_0 (* t_0 (exp im)))))
double code(double re, double im) {
	return (0.5 * sin(re)) * (exp(0.0 - im) + exp(im));
}
double code(double re, double im) {
	double t_0 = 0.5 * sin(re);
	return fma(exp(-im), t_0, (t_0 * exp(im)));
}

Error

Bits error versus re

Bits error versus im

Derivation

  1. Initial program 0.1

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{0 - im} + e^{im}\right) \]
  2. Using strategy rm
  3. Applied distribute-rgt-in_binary640.1

    \[\leadsto \color{blue}{e^{0 - im} \cdot \left(0.5 \cdot \sin re\right) + e^{im} \cdot \left(0.5 \cdot \sin re\right)} \]
  4. Applied fma-def_binary640.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(e^{0 - im}, 0.5 \cdot \sin re, e^{im} \cdot \left(0.5 \cdot \sin re\right)\right)} \]
  5. Final simplification0.1

    \[\leadsto \mathsf{fma}\left(e^{-im}, 0.5 \cdot \sin re, \left(0.5 \cdot \sin re\right) \cdot e^{im}\right) \]

Reproduce

herbie shell --seed 2021211 
(FPCore (re im)
  :name "math.sin on complex, real part"
  :precision binary64
  (* (* 0.5 (sin re)) (+ (exp (- 0.0 im)) (exp im))))