Average Error: 58.0 → 0.8
Time: 8.4s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[0.5 \cdot \left(\cos re \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)
0.5 \cdot \left(\cos re \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 r274105 = 0.5;
        double r274106 = re;
        double r274107 = cos(r274106);
        double r274108 = r274105 * r274107;
        double r274109 = 0.0;
        double r274110 = im;
        double r274111 = r274109 - r274110;
        double r274112 = exp(r274111);
        double r274113 = exp(r274110);
        double r274114 = r274112 - r274113;
        double r274115 = r274108 * r274114;
        return r274115;
}

double f(double re, double im) {
        double r274116 = 0.5;
        double r274117 = re;
        double r274118 = cos(r274117);
        double r274119 = 0.3333333333333333;
        double r274120 = im;
        double r274121 = 3.0;
        double r274122 = pow(r274120, r274121);
        double r274123 = r274119 * r274122;
        double r274124 = 0.016666666666666666;
        double r274125 = 5.0;
        double r274126 = pow(r274120, r274125);
        double r274127 = r274124 * r274126;
        double r274128 = 2.0;
        double r274129 = r274128 * r274120;
        double r274130 = r274127 + r274129;
        double r274131 = r274123 + r274130;
        double r274132 = -r274131;
        double r274133 = r274118 * r274132;
        double r274134 = r274116 * r274133;
        return r274134;
}

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.8
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.166666666666666657 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.00833333333333333322 \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.8

    \[\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-*l*0.8

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

    \[\leadsto 0.5 \cdot \left(\cos re \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 2020062 
(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))))