Average Error: 57.9 → 0.8
Time: 39.5s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos re\right) \cdot \left(\left(\frac{-1}{3} \cdot \left(im \cdot \left(im \cdot im\right)\right) - {im}^{5} \cdot \frac{1}{60}\right) - 2 \cdot im\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left(0.5 \cdot \cos re\right) \cdot \left(\left(\frac{-1}{3} \cdot \left(im \cdot \left(im \cdot im\right)\right) - {im}^{5} \cdot \frac{1}{60}\right) - 2 \cdot im\right)
double f(double re, double im) {
        double r6918716 = 0.5;
        double r6918717 = re;
        double r6918718 = cos(r6918717);
        double r6918719 = r6918716 * r6918718;
        double r6918720 = 0.0;
        double r6918721 = im;
        double r6918722 = r6918720 - r6918721;
        double r6918723 = exp(r6918722);
        double r6918724 = exp(r6918721);
        double r6918725 = r6918723 - r6918724;
        double r6918726 = r6918719 * r6918725;
        return r6918726;
}

double f(double re, double im) {
        double r6918727 = 0.5;
        double r6918728 = re;
        double r6918729 = cos(r6918728);
        double r6918730 = r6918727 * r6918729;
        double r6918731 = -0.3333333333333333;
        double r6918732 = im;
        double r6918733 = r6918732 * r6918732;
        double r6918734 = r6918732 * r6918733;
        double r6918735 = r6918731 * r6918734;
        double r6918736 = 5.0;
        double r6918737 = pow(r6918732, r6918736);
        double r6918738 = 0.016666666666666666;
        double r6918739 = r6918737 * r6918738;
        double r6918740 = r6918735 - r6918739;
        double r6918741 = 2.0;
        double r6918742 = r6918741 * r6918732;
        double r6918743 = r6918740 - r6918742;
        double r6918744 = r6918730 * r6918743;
        return r6918744;
}

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.9
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.9

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

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

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

Reproduce

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