Average Error: 58.2 → 0.7
Time: 11.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}{60} \cdot {im}^{5} + 2 \cdot im\right) + \frac{1}{3} \cdot {im}^{3}\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}{60} \cdot {im}^{5} + 2 \cdot im\right) + \frac{1}{3} \cdot {im}^{3}\right)\right)
double f(double re, double im) {
        double r148726 = 0.5;
        double r148727 = re;
        double r148728 = cos(r148727);
        double r148729 = r148726 * r148728;
        double r148730 = 0.0;
        double r148731 = im;
        double r148732 = r148730 - r148731;
        double r148733 = exp(r148732);
        double r148734 = exp(r148731);
        double r148735 = r148733 - r148734;
        double r148736 = r148729 * r148735;
        return r148736;
}

double f(double re, double im) {
        double r148737 = 0.5;
        double r148738 = re;
        double r148739 = cos(r148738);
        double r148740 = r148737 * r148739;
        double r148741 = 0.016666666666666666;
        double r148742 = im;
        double r148743 = 5.0;
        double r148744 = pow(r148742, r148743);
        double r148745 = r148741 * r148744;
        double r148746 = 2.0;
        double r148747 = r148746 * r148742;
        double r148748 = r148745 + r148747;
        double r148749 = 0.3333333333333333;
        double r148750 = 3.0;
        double r148751 = pow(r148742, r148750);
        double r148752 = r148749 * r148751;
        double r148753 = r148748 + r148752;
        double r148754 = -r148753;
        double r148755 = r148740 * r148754;
        return r148755;
}

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.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.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 +-commutative0.7

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

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

Reproduce

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