Average Error: 58.1 → 0.8
Time: 30.9s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos re\right) \cdot \left({im}^{3} \cdot \frac{-1}{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(0.5 \cdot \cos re\right) \cdot \left({im}^{3} \cdot \frac{-1}{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r152553 = 0.5;
        double r152554 = re;
        double r152555 = cos(r152554);
        double r152556 = r152553 * r152555;
        double r152557 = 0.0;
        double r152558 = im;
        double r152559 = r152557 - r152558;
        double r152560 = exp(r152559);
        double r152561 = exp(r152558);
        double r152562 = r152560 - r152561;
        double r152563 = r152556 * r152562;
        return r152563;
}

double f(double re, double im) {
        double r152564 = 0.5;
        double r152565 = re;
        double r152566 = cos(r152565);
        double r152567 = r152564 * r152566;
        double r152568 = im;
        double r152569 = 3.0;
        double r152570 = pow(r152568, r152569);
        double r152571 = -0.3333333333333333;
        double r152572 = r152570 * r152571;
        double r152573 = 0.016666666666666666;
        double r152574 = 5.0;
        double r152575 = pow(r152568, r152574);
        double r152576 = r152573 * r152575;
        double r152577 = 2.0;
        double r152578 = r152577 * r152568;
        double r152579 = r152576 + r152578;
        double r152580 = r152572 - r152579;
        double r152581 = r152567 * r152580;
        return r152581;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 58.1

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

    \[\leadsto \left(0.5 \cdot \cos 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.8

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left({im}^{3} \cdot \frac{-1}{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)}\]
  4. Final simplification0.8

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

Reproduce

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

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

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))