Average Error: 58.0 → 0.6
Time: 25.9s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\cos re \cdot \left(0.5 \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\cos re \cdot \left(0.5 \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\right)
double f(double re, double im) {
        double r149069 = 0.5;
        double r149070 = re;
        double r149071 = cos(r149070);
        double r149072 = r149069 * r149071;
        double r149073 = 0.0;
        double r149074 = im;
        double r149075 = r149073 - r149074;
        double r149076 = exp(r149075);
        double r149077 = exp(r149074);
        double r149078 = r149076 - r149077;
        double r149079 = r149072 * r149078;
        return r149079;
}

double f(double re, double im) {
        double r149080 = re;
        double r149081 = cos(r149080);
        double r149082 = 0.5;
        double r149083 = 0.3333333333333333;
        double r149084 = im;
        double r149085 = 3.0;
        double r149086 = pow(r149084, r149085);
        double r149087 = r149083 * r149086;
        double r149088 = 0.016666666666666666;
        double r149089 = 5.0;
        double r149090 = pow(r149084, r149089);
        double r149091 = r149088 * r149090;
        double r149092 = 2.0;
        double r149093 = r149092 * r149084;
        double r149094 = r149091 + r149093;
        double r149095 = r149087 + r149094;
        double r149096 = -r149095;
        double r149097 = r149082 * r149096;
        double r149098 = r149081 * r149097;
        return r149098;
}

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.0
Target0.3
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.0

    \[\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 distribute-neg-in0.6

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

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

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

Reproduce

herbie shell --seed 2019294 
(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))))