Average Error: 58.0 → 0.8
Time: 38.8s
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 r7694585 = 0.5;
        double r7694586 = re;
        double r7694587 = cos(r7694586);
        double r7694588 = r7694585 * r7694587;
        double r7694589 = 0.0;
        double r7694590 = im;
        double r7694591 = r7694589 - r7694590;
        double r7694592 = exp(r7694591);
        double r7694593 = exp(r7694590);
        double r7694594 = r7694592 - r7694593;
        double r7694595 = r7694588 * r7694594;
        return r7694595;
}

double f(double re, double im) {
        double r7694596 = 0.5;
        double r7694597 = re;
        double r7694598 = cos(r7694597);
        double r7694599 = r7694596 * r7694598;
        double r7694600 = -0.3333333333333333;
        double r7694601 = im;
        double r7694602 = r7694601 * r7694601;
        double r7694603 = r7694601 * r7694602;
        double r7694604 = r7694600 * r7694603;
        double r7694605 = 5.0;
        double r7694606 = pow(r7694601, r7694605);
        double r7694607 = 0.016666666666666666;
        double r7694608 = r7694606 * r7694607;
        double r7694609 = r7694604 - r7694608;
        double r7694610 = 2.0;
        double r7694611 = r7694610 * r7694601;
        double r7694612 = r7694609 - r7694611;
        double r7694613 = r7694599 * r7694612;
        return r7694613;
}

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.0
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 58.0

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