Average Error: 58.1 → 0.7
Time: 41.2s
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 r8968771 = 0.5;
        double r8968772 = re;
        double r8968773 = cos(r8968772);
        double r8968774 = r8968771 * r8968773;
        double r8968775 = 0.0;
        double r8968776 = im;
        double r8968777 = r8968775 - r8968776;
        double r8968778 = exp(r8968777);
        double r8968779 = exp(r8968776);
        double r8968780 = r8968778 - r8968779;
        double r8968781 = r8968774 * r8968780;
        return r8968781;
}

double f(double re, double im) {
        double r8968782 = 0.5;
        double r8968783 = re;
        double r8968784 = cos(r8968783);
        double r8968785 = r8968782 * r8968784;
        double r8968786 = -0.3333333333333333;
        double r8968787 = im;
        double r8968788 = r8968787 * r8968787;
        double r8968789 = r8968787 * r8968788;
        double r8968790 = r8968786 * r8968789;
        double r8968791 = 5.0;
        double r8968792 = pow(r8968787, r8968791);
        double r8968793 = 0.016666666666666666;
        double r8968794 = r8968792 * r8968793;
        double r8968795 = r8968790 - r8968794;
        double r8968796 = 2.0;
        double r8968797 = r8968796 * r8968787;
        double r8968798 = r8968795 - r8968797;
        double r8968799 = r8968785 * r8968798;
        return r8968799;
}

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.2
Herbie0.7
\[\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 58.1

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

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

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

    \[\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 2019129 
(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))))