Average Error: 43.9 → 0.8
Time: 11.1s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)
double f(double re, double im) {
        double r209337 = 0.5;
        double r209338 = re;
        double r209339 = sin(r209338);
        double r209340 = r209337 * r209339;
        double r209341 = im;
        double r209342 = -r209341;
        double r209343 = exp(r209342);
        double r209344 = exp(r209341);
        double r209345 = r209343 - r209344;
        double r209346 = r209340 * r209345;
        return r209346;
}

double f(double re, double im) {
        double r209347 = 0.5;
        double r209348 = re;
        double r209349 = sin(r209348);
        double r209350 = r209347 * r209349;
        double r209351 = 0.3333333333333333;
        double r209352 = im;
        double r209353 = 3.0;
        double r209354 = pow(r209352, r209353);
        double r209355 = r209351 * r209354;
        double r209356 = 0.016666666666666666;
        double r209357 = 5.0;
        double r209358 = pow(r209352, r209357);
        double r209359 = r209356 * r209358;
        double r209360 = 2.0;
        double r209361 = r209360 * r209352;
        double r209362 = r209359 + r209361;
        double r209363 = r209355 + r209362;
        double r209364 = -r209363;
        double r209365 = r209350 * r209364;
        return r209365;
}

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

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

    \[\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. Final simplification0.8

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

Reproduce

herbie shell --seed 2020034 
(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))))