Average Error: 58.0 → 0.7
Time: 17.3s
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(\frac{-1}{3} \cdot {im}^{3} - \frac{1}{60} \cdot {im}^{5}\right) - 2 \cdot im\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(\frac{-1}{3} \cdot {im}^{3} - \frac{1}{60} \cdot {im}^{5}\right) - 2 \cdot im\right)
double f(double re, double im) {
        double r201626 = 0.5;
        double r201627 = re;
        double r201628 = cos(r201627);
        double r201629 = r201626 * r201628;
        double r201630 = 0.0;
        double r201631 = im;
        double r201632 = r201630 - r201631;
        double r201633 = exp(r201632);
        double r201634 = exp(r201631);
        double r201635 = r201633 - r201634;
        double r201636 = r201629 * r201635;
        return r201636;
}

double f(double re, double im) {
        double r201637 = 0.5;
        double r201638 = re;
        double r201639 = cos(r201638);
        double r201640 = r201637 * r201639;
        double r201641 = -0.3333333333333333;
        double r201642 = im;
        double r201643 = 3.0;
        double r201644 = pow(r201642, r201643);
        double r201645 = r201641 * r201644;
        double r201646 = 0.016666666666666666;
        double r201647 = 5.0;
        double r201648 = pow(r201642, r201647);
        double r201649 = r201646 * r201648;
        double r201650 = r201645 - r201649;
        double r201651 = 2.0;
        double r201652 = r201651 * r201642;
        double r201653 = r201650 - r201652;
        double r201654 = r201640 * r201653;
        return r201654;
}

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

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left({im}^{3} \cdot \frac{-1}{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)}\]
  4. Using strategy rm
  5. Applied associate--r+0.7

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

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

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

Reproduce

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