Average Error: 58.0 → 0.8
Time: 32.1s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(\cos re \cdot \left(-im\right)\right) \cdot 1.0 - \left(\cos re \cdot \left({im}^{5} \cdot 0.008333333333333333\right) + 0.16666666666666666 \cdot \left(\left(\cos re \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left(\cos re \cdot \left(-im\right)\right) \cdot 1.0 - \left(\cos re \cdot \left({im}^{5} \cdot 0.008333333333333333\right) + 0.16666666666666666 \cdot \left(\left(\cos re \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)
double f(double re, double im) {
        double r6523380 = 0.5;
        double r6523381 = re;
        double r6523382 = cos(r6523381);
        double r6523383 = r6523380 * r6523382;
        double r6523384 = 0.0;
        double r6523385 = im;
        double r6523386 = r6523384 - r6523385;
        double r6523387 = exp(r6523386);
        double r6523388 = exp(r6523385);
        double r6523389 = r6523387 - r6523388;
        double r6523390 = r6523383 * r6523389;
        return r6523390;
}

double f(double re, double im) {
        double r6523391 = re;
        double r6523392 = cos(r6523391);
        double r6523393 = im;
        double r6523394 = -r6523393;
        double r6523395 = r6523392 * r6523394;
        double r6523396 = 1.0;
        double r6523397 = r6523395 * r6523396;
        double r6523398 = 5.0;
        double r6523399 = pow(r6523393, r6523398);
        double r6523400 = 0.008333333333333333;
        double r6523401 = r6523399 * r6523400;
        double r6523402 = r6523392 * r6523401;
        double r6523403 = 0.16666666666666666;
        double r6523404 = r6523392 * r6523393;
        double r6523405 = r6523393 * r6523393;
        double r6523406 = r6523404 * r6523405;
        double r6523407 = r6523403 * r6523406;
        double r6523408 = r6523402 + r6523407;
        double r6523409 = r6523397 - r6523408;
        return r6523409;
}

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.9

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(-\left(im \cdot \left(im \cdot \left(im \cdot \frac{1}{3}\right) + 2\right) + \frac{1}{60} \cdot {im}^{5}\right)\right)}\]
  4. Taylor expanded around inf 0.8

    \[\leadsto \color{blue}{-\left(1.0 \cdot \left(im \cdot \cos re\right) + \left(0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + 0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)\right)\right)}\]
  5. Simplified0.8

    \[\leadsto \color{blue}{\left(-1.0\right) \cdot \left(im \cdot \cos re\right) - \left(\cos re \cdot \left(0.008333333333333333 \cdot {im}^{5}\right) + 0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot \left(im \cdot \cos re\right)\right)\right)}\]
  6. Final simplification0.8

    \[\leadsto \left(\cos re \cdot \left(-im\right)\right) \cdot 1.0 - \left(\cos re \cdot \left({im}^{5} \cdot 0.008333333333333333\right) + 0.16666666666666666 \cdot \left(\left(\cos re \cdot im\right) \cdot \left(im \cdot im\right)\right)\right)\]

Reproduce

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