Average Error: 58.0 → 0.7
Time: 9.6s
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 r366053 = 0.5;
        double r366054 = re;
        double r366055 = cos(r366054);
        double r366056 = r366053 * r366055;
        double r366057 = 0.0;
        double r366058 = im;
        double r366059 = r366057 - r366058;
        double r366060 = exp(r366059);
        double r366061 = exp(r366058);
        double r366062 = r366060 - r366061;
        double r366063 = r366056 * r366062;
        return r366063;
}

double f(double re, double im) {
        double r366064 = 0.5;
        double r366065 = re;
        double r366066 = cos(r366065);
        double r366067 = r366064 * r366066;
        double r366068 = 0.3333333333333333;
        double r366069 = im;
        double r366070 = 3.0;
        double r366071 = pow(r366069, r366070);
        double r366072 = r366068 * r366071;
        double r366073 = 0.016666666666666666;
        double r366074 = 5.0;
        double r366075 = pow(r366069, r366074);
        double r366076 = r366073 * r366075;
        double r366077 = r366072 + r366076;
        double r366078 = 2.0;
        double r366079 = r366078 * r366069;
        double r366080 = r366077 + r366079;
        double r366081 = -r366080;
        double r366082 = r366067 * r366081;
        return r366082;
}

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

    \[\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 2019344 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

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