Average Error: 43.2 → 1.1
Time: 27.1s
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)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\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)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)
double f(double re, double im) {
        double r234164 = 0.5;
        double r234165 = re;
        double r234166 = sin(r234165);
        double r234167 = r234164 * r234166;
        double r234168 = im;
        double r234169 = -r234168;
        double r234170 = exp(r234169);
        double r234171 = exp(r234168);
        double r234172 = r234170 - r234171;
        double r234173 = r234167 * r234172;
        return r234173;
}

double f(double re, double im) {
        double r234174 = 0.16666666666666666;
        double r234175 = re;
        double r234176 = sin(r234175);
        double r234177 = im;
        double r234178 = 3.0;
        double r234179 = pow(r234177, r234178);
        double r234180 = r234176 * r234179;
        double r234181 = exp(r234180);
        double r234182 = log(r234181);
        double r234183 = r234174 * r234182;
        double r234184 = -r234183;
        double r234185 = 0.008333333333333333;
        double r234186 = 5.0;
        double r234187 = pow(r234177, r234186);
        double r234188 = r234185 * r234187;
        double r234189 = 1.0;
        double r234190 = r234189 * r234177;
        double r234191 = r234188 + r234190;
        double r234192 = r234176 * r234191;
        double r234193 = r234184 - r234192;
        return r234193;
}

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

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

    \[\leadsto \color{blue}{\left(-0.1666666666666666574148081281236954964697 \cdot \left(\sin re \cdot {im}^{3}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)}\]
  6. Using strategy rm
  7. Applied add-log-exp1.1

    \[\leadsto \left(-0.1666666666666666574148081281236954964697 \cdot \color{blue}{\log \left(e^{\sin re \cdot {im}^{3}}\right)}\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\]
  8. Final simplification1.1

    \[\leadsto \left(-0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\sin re \cdot {im}^{3}}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\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))))