Average Error: 58.3 → 0.6
Time: 48.5s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\cos re \cdot \left(\left(0.5 \cdot im\right) \cdot \left(im \cdot \left(\frac{-1}{3} \cdot im\right) + -2\right)\right) + \left({im}^{5} \cdot \frac{-1}{60}\right) \cdot \left(\cos re \cdot 0.5\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\cos re \cdot \left(\left(0.5 \cdot im\right) \cdot \left(im \cdot \left(\frac{-1}{3} \cdot im\right) + -2\right)\right) + \left({im}^{5} \cdot \frac{-1}{60}\right) \cdot \left(\cos re \cdot 0.5\right)
double f(double re, double im) {
        double r51966756 = 0.5;
        double r51966757 = re;
        double r51966758 = cos(r51966757);
        double r51966759 = r51966756 * r51966758;
        double r51966760 = 0.0;
        double r51966761 = im;
        double r51966762 = r51966760 - r51966761;
        double r51966763 = exp(r51966762);
        double r51966764 = exp(r51966761);
        double r51966765 = r51966763 - r51966764;
        double r51966766 = r51966759 * r51966765;
        return r51966766;
}

double f(double re, double im) {
        double r51966767 = re;
        double r51966768 = cos(r51966767);
        double r51966769 = 0.5;
        double r51966770 = im;
        double r51966771 = r51966769 * r51966770;
        double r51966772 = -0.3333333333333333;
        double r51966773 = r51966772 * r51966770;
        double r51966774 = r51966770 * r51966773;
        double r51966775 = -2.0;
        double r51966776 = r51966774 + r51966775;
        double r51966777 = r51966771 * r51966776;
        double r51966778 = r51966768 * r51966777;
        double r51966779 = 5.0;
        double r51966780 = pow(r51966770, r51966779);
        double r51966781 = -0.016666666666666666;
        double r51966782 = r51966780 * r51966781;
        double r51966783 = r51966768 * r51966769;
        double r51966784 = r51966782 * r51966783;
        double r51966785 = r51966778 + r51966784;
        return r51966785;
}

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.3
Target0.2
Herbie0.6
\[\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.3

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

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

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{60} \cdot {im}^{5} - \left(\left(\frac{1}{3} \cdot im\right) \cdot im + 2\right) \cdot im\right)}\]
  4. Using strategy rm
  5. Applied add-log-exp0.7

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\frac{-1}{60} \cdot {im}^{5} - \left(\color{blue}{\log \left(e^{\left(\frac{1}{3} \cdot im\right) \cdot im}\right)} + 2\right) \cdot im\right)\]
  6. Using strategy rm
  7. Applied sub-neg0.7

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

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

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

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

Reproduce

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