Average Error: 58.2 → 0.7
Time: 19.5s
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 r126928 = 0.5;
        double r126929 = re;
        double r126930 = cos(r126929);
        double r126931 = r126928 * r126930;
        double r126932 = 0.0;
        double r126933 = im;
        double r126934 = r126932 - r126933;
        double r126935 = exp(r126934);
        double r126936 = exp(r126933);
        double r126937 = r126935 - r126936;
        double r126938 = r126931 * r126937;
        return r126938;
}

double f(double re, double im) {
        double r126939 = 0.5;
        double r126940 = re;
        double r126941 = cos(r126940);
        double r126942 = r126939 * r126941;
        double r126943 = 0.3333333333333333;
        double r126944 = im;
        double r126945 = 3.0;
        double r126946 = pow(r126944, r126945);
        double r126947 = r126943 * r126946;
        double r126948 = 0.016666666666666666;
        double r126949 = 5.0;
        double r126950 = pow(r126944, r126949);
        double r126951 = r126948 * r126950;
        double r126952 = r126947 + r126951;
        double r126953 = 2.0;
        double r126954 = r126953 * r126944;
        double r126955 = r126952 + r126954;
        double r126956 = -r126955;
        double r126957 = r126942 * r126956;
        return r126957;
}

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

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.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. Using strategy rm
  4. Applied associate-+r+0.7

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

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