Average Error: 58.1 → 0.7
Time: 8.8s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(\left(0.5 \cdot \cos re\right) \cdot {im}^{3}\right) \cdot \frac{-1}{3} + \left(0.5 \cdot \cos re\right) \cdot \left(-\left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(\left(0.5 \cdot \cos re\right) \cdot {im}^{3}\right) \cdot \frac{-1}{3} + \left(0.5 \cdot \cos re\right) \cdot \left(-\left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r195587 = 0.5;
        double r195588 = re;
        double r195589 = cos(r195588);
        double r195590 = r195587 * r195589;
        double r195591 = 0.0;
        double r195592 = im;
        double r195593 = r195591 - r195592;
        double r195594 = exp(r195593);
        double r195595 = exp(r195592);
        double r195596 = r195594 - r195595;
        double r195597 = r195590 * r195596;
        return r195597;
}

double f(double re, double im) {
        double r195598 = 0.5;
        double r195599 = re;
        double r195600 = cos(r195599);
        double r195601 = r195598 * r195600;
        double r195602 = im;
        double r195603 = 3.0;
        double r195604 = pow(r195602, r195603);
        double r195605 = r195601 * r195604;
        double r195606 = -0.3333333333333333;
        double r195607 = r195605 * r195606;
        double r195608 = 0.016666666666666666;
        double r195609 = 5.0;
        double r195610 = pow(r195602, r195609);
        double r195611 = r195608 * r195610;
        double r195612 = 2.0;
        double r195613 = r195612 * r195602;
        double r195614 = r195611 + r195613;
        double r195615 = -r195614;
        double r195616 = r195601 * r195615;
        double r195617 = r195607 + r195616;
        return r195617;
}

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

    \[\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 distribute-neg-in0.7

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

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

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

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

Reproduce

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