Average Error: 44.1 → 0.9
Time: 14.3s
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 r258400 = 0.5;
        double r258401 = re;
        double r258402 = sin(r258401);
        double r258403 = r258400 * r258402;
        double r258404 = im;
        double r258405 = -r258404;
        double r258406 = exp(r258405);
        double r258407 = exp(r258404);
        double r258408 = r258406 - r258407;
        double r258409 = r258403 * r258408;
        return r258409;
}

double f(double re, double im) {
        double r258410 = 0.5;
        double r258411 = re;
        double r258412 = sin(r258411);
        double r258413 = r258410 * r258412;
        double r258414 = 0.3333333333333333;
        double r258415 = im;
        double r258416 = 3.0;
        double r258417 = pow(r258415, r258416);
        double r258418 = r258414 * r258417;
        double r258419 = 0.016666666666666666;
        double r258420 = 5.0;
        double r258421 = pow(r258415, r258420);
        double r258422 = r258419 * r258421;
        double r258423 = 2.0;
        double r258424 = r258423 * r258415;
        double r258425 = r258422 + r258424;
        double r258426 = r258418 + r258425;
        double r258427 = -r258426;
        double r258428 = r258413 * r258427;
        return r258428;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original44.1
Target0.4
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 44.1

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

    \[\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 2019322 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 0.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

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