Average Error: 43.2 → 1.1
Time: 36.2s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[-\left(0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\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)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
-\left(0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\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)
double f(double re, double im) {
        double r171705 = 0.5;
        double r171706 = re;
        double r171707 = sin(r171706);
        double r171708 = r171705 * r171707;
        double r171709 = im;
        double r171710 = -r171709;
        double r171711 = exp(r171710);
        double r171712 = exp(r171709);
        double r171713 = r171711 - r171712;
        double r171714 = r171708 * r171713;
        return r171714;
}

double f(double re, double im) {
        double r171715 = 0.16666666666666666;
        double r171716 = re;
        double r171717 = sin(r171716);
        double r171718 = im;
        double r171719 = 3.0;
        double r171720 = pow(r171718, r171719);
        double r171721 = r171717 * r171720;
        double r171722 = exp(r171721);
        double r171723 = log(r171722);
        double r171724 = r171715 * r171723;
        double r171725 = 1.0;
        double r171726 = r171717 * r171718;
        double r171727 = r171725 * r171726;
        double r171728 = 0.008333333333333333;
        double r171729 = 5.0;
        double r171730 = pow(r171718, r171729);
        double r171731 = r171717 * r171730;
        double r171732 = r171728 * r171731;
        double r171733 = r171727 + r171732;
        double r171734 = r171724 + r171733;
        double r171735 = -r171734;
        return r171735;
}

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.2
Target0.3
Herbie1.1
\[\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.2

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

    \[\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. Taylor expanded around inf 0.7

    \[\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)}\]
  4. Using strategy rm
  5. Applied add-log-exp1.1

    \[\leadsto -\left(0.1666666666666666574148081281236954964697 \cdot \color{blue}{\log \left(e^{\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)\]
  6. Final simplification1.1

    \[\leadsto -\left(0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\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)\]

Reproduce

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

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