Average Error: 58.2 → 28.9
Time: 27.3s
Precision: 64
Internal Precision: 1344
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[0.5 \cdot (e^{(\left(im \cdot im\right) \cdot \left((-3 \cdot im + -2)_*\right) + \left(im \cdot -2\right))_*} - 1)^*\]

Error

Bits error versus re

Bits error versus im

Target

Original58.2
Target0.2
Herbie28.9
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(\frac{1}{6} \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(\frac{1}{120} \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right) \cdot im\right)\\ \mathbf{else}:\\ \;\;\;\;\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.2

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
  2. Initial simplification58.3

    \[\leadsto 0.5 \cdot \left(\frac{\cos re}{e^{im}} - e^{im} \cdot \cos re\right)\]
  3. Taylor expanded around 0 31.8

    \[\leadsto 0.5 \cdot \color{blue}{\left({re}^{2} \cdot im - \left(\frac{1}{3} \cdot {im}^{3} + 2 \cdot im\right)\right)}\]
  4. Simplified31.8

    \[\leadsto 0.5 \cdot \color{blue}{\left((\frac{-1}{3} \cdot \left(im \cdot im\right) + \left((re \cdot re + -2)_*\right))_* \cdot im\right)}\]
  5. Using strategy rm
  6. Applied expm1-log1p-u31.8

    \[\leadsto 0.5 \cdot \color{blue}{(e^{\log_* (1 + (\frac{-1}{3} \cdot \left(im \cdot im\right) + \left((re \cdot re + -2)_*\right))_* \cdot im)} - 1)^*}\]
  7. Taylor expanded around 0 28.9

    \[\leadsto 0.5 \cdot (e^{\color{blue}{-\left(3 \cdot {im}^{3} + \left(2 \cdot {im}^{2} + 2 \cdot im\right)\right)}} - 1)^*\]
  8. Simplified28.9

    \[\leadsto 0.5 \cdot (e^{\color{blue}{(\left(im \cdot im\right) \cdot \left((-3 \cdot im + -2)_*\right) + \left(-2 \cdot im\right))_*}} - 1)^*\]
  9. Final simplification28.9

    \[\leadsto 0.5 \cdot (e^{(\left(im \cdot im\right) \cdot \left((-3 \cdot im + -2)_*\right) + \left(im \cdot -2\right))_*} - 1)^*\]

Runtime

Time bar (total: 27.3s)Debug logProfile

herbie shell --seed 2018255 +o rules:numerics
(FPCore (re im)
  :name "math.sin on complex, imaginary part"

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))