Average Error: 58.1 → 0.7
Time: 27.7s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(im \cdot 1.0\right) \cdot \left(-\cos re\right) - \cos re \cdot \left(0.008333333333333333 \cdot {im}^{5} + 0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left(im \cdot 1.0\right) \cdot \left(-\cos re\right) - \cos re \cdot \left(0.008333333333333333 \cdot {im}^{5} + 0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right)
double f(double re, double im) {
        double r3824880 = 0.5;
        double r3824881 = re;
        double r3824882 = cos(r3824881);
        double r3824883 = r3824880 * r3824882;
        double r3824884 = 0.0;
        double r3824885 = im;
        double r3824886 = r3824884 - r3824885;
        double r3824887 = exp(r3824886);
        double r3824888 = exp(r3824885);
        double r3824889 = r3824887 - r3824888;
        double r3824890 = r3824883 * r3824889;
        return r3824890;
}

double f(double re, double im) {
        double r3824891 = im;
        double r3824892 = 1.0;
        double r3824893 = r3824891 * r3824892;
        double r3824894 = re;
        double r3824895 = cos(r3824894);
        double r3824896 = -r3824895;
        double r3824897 = r3824893 * r3824896;
        double r3824898 = 0.008333333333333333;
        double r3824899 = 5.0;
        double r3824900 = pow(r3824891, r3824899);
        double r3824901 = r3824898 * r3824900;
        double r3824902 = 0.16666666666666666;
        double r3824903 = r3824891 * r3824891;
        double r3824904 = r3824903 * r3824891;
        double r3824905 = r3824902 * r3824904;
        double r3824906 = r3824901 + r3824905;
        double r3824907 = r3824895 * r3824906;
        double r3824908 = r3824897 - r3824907;
        return r3824908;
}

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.2
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(\frac{1}{6} \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(\frac{1}{120} \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 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.1

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

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

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot \left(\left(im \cdot im\right) \cdot im\right) - \left(\frac{1}{60} \cdot {im}^{5} + \left(im + im\right)\right)\right)}\]
  4. Taylor expanded around inf 0.7

    \[\leadsto \color{blue}{-\left(1.0 \cdot \left(im \cdot \cos re\right) + \left(0.16666666666666666 \cdot \left({im}^{3} \cdot \cos re\right) + 0.008333333333333333 \cdot \left({im}^{5} \cdot \cos re\right)\right)\right)}\]
  5. Simplified0.7

    \[\leadsto \color{blue}{\left(-\left(im \cdot 1.0\right) \cdot \cos re\right) - \cos re \cdot \left({im}^{5} \cdot 0.008333333333333333 + \left(\left(im \cdot im\right) \cdot im\right) \cdot 0.16666666666666666\right)}\]
  6. Final simplification0.7

    \[\leadsto \left(im \cdot 1.0\right) \cdot \left(-\cos re\right) - \cos re \cdot \left(0.008333333333333333 \cdot {im}^{5} + 0.16666666666666666 \cdot \left(\left(im \cdot im\right) \cdot im\right)\right)\]

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))

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