Average Error: 58.1 → 0.8
Time: 34.4s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\left(\frac{-{im}^{3}}{3} - 2 \cdot im\right) - \frac{{im}^{5}}{60}\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(\frac{1}{2} \cdot \cos re\right) \cdot \left(\left(\frac{-{im}^{3}}{3} - 2 \cdot im\right) - \frac{{im}^{5}}{60}\right)
double f(double re, double im) {
        double r160739 = 0.5;
        double r160740 = re;
        double r160741 = cos(r160740);
        double r160742 = r160739 * r160741;
        double r160743 = 0.0;
        double r160744 = im;
        double r160745 = r160743 - r160744;
        double r160746 = exp(r160745);
        double r160747 = exp(r160744);
        double r160748 = r160746 - r160747;
        double r160749 = r160742 * r160748;
        return r160749;
}

double f(double re, double im) {
        double r160750 = 1.0;
        double r160751 = 2.0;
        double r160752 = r160750 / r160751;
        double r160753 = re;
        double r160754 = cos(r160753);
        double r160755 = r160752 * r160754;
        double r160756 = im;
        double r160757 = 3.0;
        double r160758 = pow(r160756, r160757);
        double r160759 = -r160758;
        double r160760 = r160759 / r160757;
        double r160761 = 2.0;
        double r160762 = r160761 * r160756;
        double r160763 = r160760 - r160762;
        double r160764 = 5.0;
        double r160765 = pow(r160756, r160764);
        double r160766 = 60.0;
        double r160767 = r160765 / r160766;
        double r160768 = r160763 - r160767;
        double r160769 = r160755 * r160768;
        return r160769;
}

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.8
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.1666666666666666574148081281236954964697 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333217685101601546193705872 \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.0 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.1

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.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(\frac{-{im}^{3}}{3} - 2 \cdot im\right) - \frac{{im}^{5}}{60}\right)}\]
  4. Final simplification0.8

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

Reproduce

herbie shell --seed 2019303 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))