Average Error: 58.0 → 0.8
Time: 35.6s
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 r170250 = 0.5;
        double r170251 = re;
        double r170252 = cos(r170251);
        double r170253 = r170250 * r170252;
        double r170254 = 0.0;
        double r170255 = im;
        double r170256 = r170254 - r170255;
        double r170257 = exp(r170256);
        double r170258 = exp(r170255);
        double r170259 = r170257 - r170258;
        double r170260 = r170253 * r170259;
        return r170260;
}

double f(double re, double im) {
        double r170261 = 0.5;
        double r170262 = re;
        double r170263 = cos(r170262);
        double r170264 = r170261 * r170263;
        double r170265 = im;
        double r170266 = 3.0;
        double r170267 = pow(r170265, r170266);
        double r170268 = -0.3333333333333333;
        double r170269 = r170267 * r170268;
        double r170270 = 0.016666666666666666;
        double r170271 = 5.0;
        double r170272 = pow(r170265, r170271);
        double r170273 = r170270 * r170272;
        double r170274 = 2.0;
        double r170275 = r170274 * r170265;
        double r170276 = r170273 + r170275;
        double r170277 = r170269 - r170276;
        double r170278 = r170264 * r170277;
        return r170278;
}

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.0
Target0.2
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.0

    \[\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 2019304 
(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))))