Average Error: 58.0 → 0.8
Time: 20.4s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos re\right) \cdot \left({im}^{3} \cdot \frac{-1}{3}\right) + \cos re \cdot \left(0.5 \cdot \left({im}^{5} \cdot \frac{-1}{60} - 2 \cdot im\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(0.5 \cdot \cos re\right) \cdot \left({im}^{3} \cdot \frac{-1}{3}\right) + \cos re \cdot \left(0.5 \cdot \left({im}^{5} \cdot \frac{-1}{60} - 2 \cdot im\right)\right)
double f(double re, double im) {
        double r290501 = 0.5;
        double r290502 = re;
        double r290503 = cos(r290502);
        double r290504 = r290501 * r290503;
        double r290505 = 0.0;
        double r290506 = im;
        double r290507 = r290505 - r290506;
        double r290508 = exp(r290507);
        double r290509 = exp(r290506);
        double r290510 = r290508 - r290509;
        double r290511 = r290504 * r290510;
        return r290511;
}

double f(double re, double im) {
        double r290512 = 0.5;
        double r290513 = re;
        double r290514 = cos(r290513);
        double r290515 = r290512 * r290514;
        double r290516 = im;
        double r290517 = 3.0;
        double r290518 = pow(r290516, r290517);
        double r290519 = -0.3333333333333333;
        double r290520 = r290518 * r290519;
        double r290521 = r290515 * r290520;
        double r290522 = 5.0;
        double r290523 = pow(r290516, r290522);
        double r290524 = -0.016666666666666666;
        double r290525 = r290523 * r290524;
        double r290526 = 2.0;
        double r290527 = r290526 * r290516;
        double r290528 = r290525 - r290527;
        double r290529 = r290512 * r290528;
        double r290530 = r290514 * r290529;
        double r290531 = r290521 + r290530;
        return r290531;
}

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

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

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

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

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (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))))