Average Error: 57.8 → 0.8
Time: 1.8m
Precision: 64
Internal Precision: 1344
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(\left(\cos re \cdot \left(-0.5\right)\right) \cdot \left(im \cdot \left(im \cdot \left(\frac{1}{3} \cdot im\right)\right)\right) + \left(\cos re \cdot \left(-0.5\right)\right) \cdot \left(im \cdot 2\right)\right) + \left(\cos re \cdot \left(-0.5\right)\right) \cdot \left({im}^{5} \cdot \frac{1}{60}\right)\]

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original57.8
Target0.3
Herbie0.8
\[\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 57.8

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

    \[\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. Applied simplify0.8

    \[\leadsto \color{blue}{\left(\cos re \cdot \left(-0.5\right)\right) \cdot (im \cdot \left((im \cdot \left(\frac{1}{3} \cdot im\right) + 2)_*\right) + \left({im}^{5} \cdot \frac{1}{60}\right))_*}\]
  4. Using strategy rm
  5. Applied fma-udef0.8

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

    \[\leadsto \color{blue}{\left(\cos re \cdot \left(-0.5\right)\right) \cdot \left(im \cdot (im \cdot \left(\frac{1}{3} \cdot im\right) + 2)_*\right) + \left(\cos re \cdot \left(-0.5\right)\right) \cdot \left({im}^{5} \cdot \frac{1}{60}\right)}\]
  7. Using strategy rm
  8. Applied fma-udef0.8

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

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

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

Runtime

Time bar (total: 1.8m)Debug logProfile

herbie shell --seed 2019053 +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))))