Average Error: 58.6 → 0.2
Time: 18.7s
Precision: 64
Internal precision: 1408
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\begin{array}{l} \mathbf{if}\;im \le 1.9183430624335127:\\ \;\;\;\;\left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right) \cdot \left(0.5 \cdot \cos re\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right)\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Target

Original58.6
Comparison5.4
Herbie0.2
\[ \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. Split input into 2 regimes.
  2. if im < 1.9183430624335127

    1. Initial program 58.8

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
    2. Applied simplify 58.8

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right)}\]
    3. Applied taylor 0.2

      \[\leadsto \left(-\left(\frac{1}{60} \cdot {im}^{5} + \left(2 \cdot im + \frac{1}{3} \cdot {im}^{3}\right)\right)\right) \cdot \left(0.5 \cdot \cos re\right)\]
    4. Taylor expanded around 0 0.2

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

    if 1.9183430624335127 < im

    1. Initial program 0.1

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
    2. Applied simplify 0.1

      \[\leadsto \color{blue}{\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right)}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions

Runtime

Time bar (total: 18.7s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (re im)
  :name "math.sin on complex, imaginary part"

  :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))))