Average Error: 57.9 → 0.8
Time: 32.2s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(\left(im \cdot im\right) \cdot \left(im \cdot \frac{-1}{3}\right)\right) \cdot \left(\cos re \cdot 0.5\right) + \left(\cos re \cdot 0.5\right) \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(im + im\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left(\left(im \cdot im\right) \cdot \left(im \cdot \frac{-1}{3}\right)\right) \cdot \left(\cos re \cdot 0.5\right) + \left(\cos re \cdot 0.5\right) \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(im + im\right)\right)
double f(double re, double im) {
        double r7745740 = 0.5;
        double r7745741 = re;
        double r7745742 = cos(r7745741);
        double r7745743 = r7745740 * r7745742;
        double r7745744 = 0.0;
        double r7745745 = im;
        double r7745746 = r7745744 - r7745745;
        double r7745747 = exp(r7745746);
        double r7745748 = exp(r7745745);
        double r7745749 = r7745747 - r7745748;
        double r7745750 = r7745743 * r7745749;
        return r7745750;
}

double f(double re, double im) {
        double r7745751 = im;
        double r7745752 = r7745751 * r7745751;
        double r7745753 = -0.3333333333333333;
        double r7745754 = r7745751 * r7745753;
        double r7745755 = r7745752 * r7745754;
        double r7745756 = re;
        double r7745757 = cos(r7745756);
        double r7745758 = 0.5;
        double r7745759 = r7745757 * r7745758;
        double r7745760 = r7745755 * r7745759;
        double r7745761 = 5.0;
        double r7745762 = pow(r7745751, r7745761);
        double r7745763 = -0.016666666666666666;
        double r7745764 = r7745762 * r7745763;
        double r7745765 = r7745751 + r7745751;
        double r7745766 = r7745764 - r7745765;
        double r7745767 = r7745759 * r7745766;
        double r7745768 = r7745760 + r7745767;
        return r7745768;
}

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({im}^{5} \cdot \frac{-1}{60} - \left(im + im\right)\right) - \left(im \cdot im\right) \cdot \left(im \cdot \frac{1}{3}\right)\right)}\]
  4. Using strategy rm
  5. Applied sub-neg0.8

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

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

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

Reproduce

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