Average Error: 58.0 → 0.7
Time: 32.1s
Precision: 64
Internal Precision: 1408
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[(im \cdot \left((\left(\frac{1}{3} \cdot im\right) \cdot im + 2)_*\right) + \left({im}^{5} \cdot \frac{1}{60}\right))_* \cdot \left(\cos re \cdot \left(-0.5\right)\right)\]

Error

Bits error versus re

Bits error versus im

Target

Original58.0
Target0.3
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.7

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

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

Runtime

Time bar (total: 32.1s)Debug logProfile

herbie shell --seed '#(1064173506 2580572819 2847706409 4129882574 1125180799 1845288547)' +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))))