Average Error: 58.1 → 0.8
Time: 9.1s
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 r253642 = 0.5;
        double r253643 = re;
        double r253644 = cos(r253643);
        double r253645 = r253642 * r253644;
        double r253646 = 0.0;
        double r253647 = im;
        double r253648 = r253646 - r253647;
        double r253649 = exp(r253648);
        double r253650 = exp(r253647);
        double r253651 = r253649 - r253650;
        double r253652 = r253645 * r253651;
        return r253652;
}

double f(double re, double im) {
        double r253653 = 0.5;
        double r253654 = re;
        double r253655 = cos(r253654);
        double r253656 = r253653 * r253655;
        double r253657 = 0.3333333333333333;
        double r253658 = im;
        double r253659 = 3.0;
        double r253660 = pow(r253658, r253659);
        double r253661 = r253657 * r253660;
        double r253662 = 0.016666666666666666;
        double r253663 = 5.0;
        double r253664 = pow(r253658, r253663);
        double r253665 = r253662 * r253664;
        double r253666 = r253661 + r253665;
        double r253667 = 2.0;
        double r253668 = r253667 * r253658;
        double r253669 = r253666 + r253668;
        double r253670 = -r253669;
        double r253671 = r253656 * r253670;
        return r253671;
}

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

    \[\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-+r+0.8

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

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