Average Error: 58.2 → 0.6
Time: 9.4s
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(-\left(\left(\frac{1}{3} \cdot {im}^{3} + \frac{1}{60} \cdot {im}^{5}\right) + 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(-\left(\left(\frac{1}{3} \cdot {im}^{3} + \frac{1}{60} \cdot {im}^{5}\right) + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r110350 = 0.5;
        double r110351 = re;
        double r110352 = cos(r110351);
        double r110353 = r110350 * r110352;
        double r110354 = 0.0;
        double r110355 = im;
        double r110356 = r110354 - r110355;
        double r110357 = exp(r110356);
        double r110358 = exp(r110355);
        double r110359 = r110357 - r110358;
        double r110360 = r110353 * r110359;
        return r110360;
}

double f(double re, double im) {
        double r110361 = 0.5;
        double r110362 = re;
        double r110363 = cos(r110362);
        double r110364 = r110361 * r110363;
        double r110365 = 0.3333333333333333;
        double r110366 = im;
        double r110367 = 3.0;
        double r110368 = pow(r110366, r110367);
        double r110369 = r110365 * r110368;
        double r110370 = 0.016666666666666666;
        double r110371 = 5.0;
        double r110372 = pow(r110366, r110371);
        double r110373 = r110370 * r110372;
        double r110374 = r110369 + r110373;
        double r110375 = 2.0;
        double r110376 = r110375 * r110366;
        double r110377 = r110374 + r110376;
        double r110378 = -r110377;
        double r110379 = r110364 * r110378;
        return r110379;
}

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.2
Target0.2
Herbie0.6
\[\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.2

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

    \[\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. Using strategy rm
  4. Applied associate-+r+0.6

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

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 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))))