Average Error: 58.3 → 0.7
Time: 30.2s
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 r8991852 = 0.5;
        double r8991853 = re;
        double r8991854 = cos(r8991853);
        double r8991855 = r8991852 * r8991854;
        double r8991856 = 0.0;
        double r8991857 = im;
        double r8991858 = r8991856 - r8991857;
        double r8991859 = exp(r8991858);
        double r8991860 = exp(r8991857);
        double r8991861 = r8991859 - r8991860;
        double r8991862 = r8991855 * r8991861;
        return r8991862;
}

double f(double re, double im) {
        double r8991863 = re;
        double r8991864 = cos(r8991863);
        double r8991865 = im;
        double r8991866 = 5.0;
        double r8991867 = pow(r8991865, r8991866);
        double r8991868 = -0.016666666666666666;
        double r8991869 = r8991867 * r8991868;
        double r8991870 = 2.0;
        double r8991871 = -0.3333333333333333;
        double r8991872 = r8991865 * r8991871;
        double r8991873 = r8991872 * r8991865;
        double r8991874 = r8991870 - r8991873;
        double r8991875 = r8991874 * r8991865;
        double r8991876 = r8991869 - r8991875;
        double r8991877 = r8991864 * r8991876;
        double r8991878 = 0.5;
        double r8991879 = r8991877 * r8991878;
        return r8991879;
}

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))))