Average Error: 58.1 → 0.7
Time: 34.9s
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({im}^{3} \cdot \frac{-1}{3} - \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(0.5 \cdot \cos re\right) \cdot \left({im}^{3} \cdot \frac{-1}{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r128667 = 0.5;
        double r128668 = re;
        double r128669 = cos(r128668);
        double r128670 = r128667 * r128669;
        double r128671 = 0.0;
        double r128672 = im;
        double r128673 = r128671 - r128672;
        double r128674 = exp(r128673);
        double r128675 = exp(r128672);
        double r128676 = r128674 - r128675;
        double r128677 = r128670 * r128676;
        return r128677;
}

double f(double re, double im) {
        double r128678 = 0.5;
        double r128679 = re;
        double r128680 = cos(r128679);
        double r128681 = r128678 * r128680;
        double r128682 = im;
        double r128683 = 3.0;
        double r128684 = pow(r128682, r128683);
        double r128685 = -0.3333333333333333;
        double r128686 = r128684 * r128685;
        double r128687 = 0.016666666666666666;
        double r128688 = 5.0;
        double r128689 = pow(r128682, r128688);
        double r128690 = r128687 * r128689;
        double r128691 = 2.0;
        double r128692 = r128691 * r128682;
        double r128693 = r128690 + r128692;
        double r128694 = r128686 - r128693;
        double r128695 = r128681 * r128694;
        return r128695;
}

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.2
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.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. 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. Final simplification0.7

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

Reproduce

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