Average Error: 58.0 → 0.7
Time: 1.0m
Precision: 64
Internal Precision: 128
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos re\right) \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(\log \left(e^{im \cdot \left(\frac{1}{3} \cdot im\right)}\right) + 2\right) \cdot im\right)\]

Error

Bits error versus re

Bits error versus im

Target

Original58.0
Target0.2
Herbie0.7
\[\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.0

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.6

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)}\]
  3. Simplified0.7

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{60} \cdot {im}^{5} - \left(\left(\frac{1}{3} \cdot im\right) \cdot im + 2\right) \cdot im\right)}\]
  4. Using strategy rm
  5. Applied add-log-exp0.7

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\frac{-1}{60} \cdot {im}^{5} - \left(\color{blue}{\log \left(e^{\left(\frac{1}{3} \cdot im\right) \cdot im}\right)} + 2\right) \cdot im\right)\]
  6. Final simplification0.7

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(\log \left(e^{im \cdot \left(\frac{1}{3} \cdot im\right)}\right) + 2\right) \cdot im\right)\]

Reproduce

herbie shell --seed 2019088 
(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))))