Average Error: 58.1 → 0.4
Time: 2.6m
Precision: 64
Internal Precision: 1344
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\begin{array}{l} \mathbf{if}\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right) \le -0.05534827214616331:\\ \;\;\;\;\frac{\cos re}{\frac{e^{im}}{0.5}} + e^{im} \cdot \left(\cos re \cdot \left(-0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot \left(-0.5\right)\right) \cdot \left({im}^{5} \cdot \frac{1}{60} + \left(\frac{1}{3} \cdot {im}^{3} + 2 \cdot im\right)\right)\\ \end{array}\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original58.1
Target0.3
Herbie0.4
\[\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 (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))) < -0.05534827214616331

    1. Initial program 0.4

      \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
    2. Using strategy rm
    3. Applied sub-neg0.4

      \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(e^{0 - im} + \left(-e^{im}\right)\right)}\]
    4. Applied distribute-lft-in0.5

      \[\leadsto \color{blue}{\left(0.5 \cdot \cos re\right) \cdot e^{0 - im} + \left(0.5 \cdot \cos re\right) \cdot \left(-e^{im}\right)}\]
    5. Applied simplify0.6

      \[\leadsto \color{blue}{\frac{\cos re}{\frac{e^{im}}{0.5}}} + \left(0.5 \cdot \cos re\right) \cdot \left(-e^{im}\right)\]

    if -0.05534827214616331 < (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im)))

    1. Initial program 58.5

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

      \[\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. Recombined 2 regimes into one program.
  4. Applied simplify0.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;\left(e^{-im} - e^{im}\right) \cdot \left(0.5 \cdot \cos re\right) \le -0.05534827214616331:\\ \;\;\;\;\frac{\cos re}{\frac{e^{im}}{0.5}} + e^{im} \cdot \left(\cos re \cdot \left(-0.5\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\cos re \cdot \left(-0.5\right)\right) \cdot \left({im}^{5} \cdot \frac{1}{60} + \left(\frac{1}{3} \cdot {im}^{3} + 2 \cdot im\right)\right)\\ \end{array}}\]

Runtime

Time bar (total: 2.6m)Debug logProfile

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