Average Error: 58.0 → 0.8
Time: 28.4s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[0.5 \cdot \left(\left({im}^{3} \cdot \frac{-1}{3} - \left(\left(im + im\right) + {im}^{5} \cdot \frac{1}{60}\right)\right) \cdot \cos re\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
0.5 \cdot \left(\left({im}^{3} \cdot \frac{-1}{3} - \left(\left(im + im\right) + {im}^{5} \cdot \frac{1}{60}\right)\right) \cdot \cos re\right)
double f(double re, double im) {
        double r272415 = 0.5;
        double r272416 = re;
        double r272417 = cos(r272416);
        double r272418 = r272415 * r272417;
        double r272419 = 0.0;
        double r272420 = im;
        double r272421 = r272419 - r272420;
        double r272422 = exp(r272421);
        double r272423 = exp(r272420);
        double r272424 = r272422 - r272423;
        double r272425 = r272418 * r272424;
        return r272425;
}

double f(double re, double im) {
        double r272426 = 0.5;
        double r272427 = im;
        double r272428 = 3.0;
        double r272429 = pow(r272427, r272428);
        double r272430 = -0.3333333333333333;
        double r272431 = r272429 * r272430;
        double r272432 = r272427 + r272427;
        double r272433 = 5.0;
        double r272434 = pow(r272427, r272433);
        double r272435 = 0.016666666666666666;
        double r272436 = r272434 * r272435;
        double r272437 = r272432 + r272436;
        double r272438 = r272431 - r272437;
        double r272439 = re;
        double r272440 = cos(r272439);
        double r272441 = r272438 * r272440;
        double r272442 = r272426 * r272441;
        return r272442;
}

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(0.1666666666666666574148081281236954964697 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.008333333333333333217685101601546193705872 \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.0 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.0

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
  2. Simplified58.0

    \[\leadsto \color{blue}{\left(\left(e^{0.0 - im} - e^{im}\right) \cdot \cos re\right) \cdot 0.5}\]
  3. Taylor expanded around 0 0.8

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

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

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

Reproduce

herbie shell --seed 2019179 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))