Average Error: 43.8 → 0.9
Time: 59.7s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(-0.1666666666666666574148081281236954964697\right) \cdot \left(\sin re \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) - \left(im \cdot 1 + {im}^{5} \cdot 0.008333333333333333217685101601546193705872\right) \cdot \sin re\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\left(-0.1666666666666666574148081281236954964697\right) \cdot \left(\sin re \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) - \left(im \cdot 1 + {im}^{5} \cdot 0.008333333333333333217685101601546193705872\right) \cdot \sin re
double f(double re, double im) {
        double r10491620 = 0.5;
        double r10491621 = re;
        double r10491622 = sin(r10491621);
        double r10491623 = r10491620 * r10491622;
        double r10491624 = im;
        double r10491625 = -r10491624;
        double r10491626 = exp(r10491625);
        double r10491627 = exp(r10491624);
        double r10491628 = r10491626 - r10491627;
        double r10491629 = r10491623 * r10491628;
        return r10491629;
}

double f(double re, double im) {
        double r10491630 = 0.16666666666666666;
        double r10491631 = -r10491630;
        double r10491632 = re;
        double r10491633 = sin(r10491632);
        double r10491634 = im;
        double r10491635 = r10491634 * r10491634;
        double r10491636 = r10491634 * r10491635;
        double r10491637 = r10491633 * r10491636;
        double r10491638 = r10491631 * r10491637;
        double r10491639 = 1.0;
        double r10491640 = r10491634 * r10491639;
        double r10491641 = 5.0;
        double r10491642 = pow(r10491634, r10491641);
        double r10491643 = 0.008333333333333333;
        double r10491644 = r10491642 * r10491643;
        double r10491645 = r10491640 + r10491644;
        double r10491646 = r10491645 * r10491633;
        double r10491647 = r10491638 - r10491646;
        return r10491647;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original43.8
Target0.3
Herbie0.9
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 43.8

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.9

    \[\leadsto \left(0.5 \cdot \sin 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 \sin re\right) \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \frac{-1}{3} - \left(im + \left(im + {im}^{5} \cdot \frac{1}{60}\right)\right)\right)}\]
  4. Taylor expanded around inf 0.9

    \[\leadsto \color{blue}{-\left(0.1666666666666666574148081281236954964697 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.008333333333333333217685101601546193705872 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)}\]
  5. Simplified0.9

    \[\leadsto \color{blue}{\left(-0.1666666666666666574148081281236954964697 \cdot \left(\sin re \cdot \left(im \cdot \left(im \cdot im\right)\right)\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)}\]
  6. Final simplification0.9

    \[\leadsto \left(-0.1666666666666666574148081281236954964697\right) \cdot \left(\sin re \cdot \left(im \cdot \left(im \cdot im\right)\right)\right) - \left(im \cdot 1 + {im}^{5} \cdot 0.008333333333333333217685101601546193705872\right) \cdot \sin re\]

Reproduce

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

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

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))