Average Error: 58.3 → 0.7
Time: 29.5s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(\cos re \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(2 - \left(im \cdot \frac{-1}{3}\right) \cdot im\right) \cdot im\right)\right) \cdot 0.5\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(\cos re \cdot \left({im}^{5} \cdot \frac{-1}{60} - \left(2 - \left(im \cdot \frac{-1}{3}\right) \cdot im\right) \cdot im\right)\right) \cdot 0.5
double f(double re, double im) {
        double r9995985 = 0.5;
        double r9995986 = re;
        double r9995987 = cos(r9995986);
        double r9995988 = r9995985 * r9995987;
        double r9995989 = 0.0;
        double r9995990 = im;
        double r9995991 = r9995989 - r9995990;
        double r9995992 = exp(r9995991);
        double r9995993 = exp(r9995990);
        double r9995994 = r9995992 - r9995993;
        double r9995995 = r9995988 * r9995994;
        return r9995995;
}

double f(double re, double im) {
        double r9995996 = re;
        double r9995997 = cos(r9995996);
        double r9995998 = im;
        double r9995999 = 5.0;
        double r9996000 = pow(r9995998, r9995999);
        double r9996001 = -0.016666666666666666;
        double r9996002 = r9996000 * r9996001;
        double r9996003 = 2.0;
        double r9996004 = -0.3333333333333333;
        double r9996005 = r9995998 * r9996004;
        double r9996006 = r9996005 * r9995998;
        double r9996007 = r9996003 - r9996006;
        double r9996008 = r9996007 * r9995998;
        double r9996009 = r9996002 - r9996008;
        double r9996010 = r9995997 * r9996009;
        double r9996011 = 0.5;
        double r9996012 = r9996010 * r9996011;
        return r9996012;
}

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

    \[\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. Simplified0.6

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\left(im \cdot \left(im \cdot im\right)\right) \cdot \frac{-1}{3} + \left(\frac{-1}{60} \cdot {im}^{5} - \left(im + im\right)\right)\right)}\]
  4. Using strategy rm
  5. Applied associate-*l*0.6

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

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

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (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))))