Average Error: 57.9 → 0.8
Time: 1.1m
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left({im}^{5} \cdot \frac{-1}{60} - im \cdot \left(2 + im \cdot \left(\frac{1}{3} \cdot im\right)\right)\right) \cdot \left(0.5 \cdot \cos re\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left({im}^{5} \cdot \frac{-1}{60} - im \cdot \left(2 + im \cdot \left(\frac{1}{3} \cdot im\right)\right)\right) \cdot \left(0.5 \cdot \cos re\right)
double f(double re, double im) {
        double r43569760 = 0.5;
        double r43569761 = re;
        double r43569762 = cos(r43569761);
        double r43569763 = r43569760 * r43569762;
        double r43569764 = 0.0;
        double r43569765 = im;
        double r43569766 = r43569764 - r43569765;
        double r43569767 = exp(r43569766);
        double r43569768 = exp(r43569765);
        double r43569769 = r43569767 - r43569768;
        double r43569770 = r43569763 * r43569769;
        return r43569770;
}

double f(double re, double im) {
        double r43569771 = im;
        double r43569772 = 5.0;
        double r43569773 = pow(r43569771, r43569772);
        double r43569774 = -0.016666666666666666;
        double r43569775 = r43569773 * r43569774;
        double r43569776 = 2.0;
        double r43569777 = 0.3333333333333333;
        double r43569778 = r43569777 * r43569771;
        double r43569779 = r43569771 * r43569778;
        double r43569780 = r43569776 + r43569779;
        double r43569781 = r43569771 * r43569780;
        double r43569782 = r43569775 - r43569781;
        double r43569783 = 0.5;
        double r43569784 = re;
        double r43569785 = cos(r43569784);
        double r43569786 = r43569783 * r43569785;
        double r43569787 = r43569782 * r43569786;
        return r43569787;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original57.9
Target0.3
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(\frac{1}{6} \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(\frac{1}{120} \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 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 57.9

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{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. Simplified0.8

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

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

Reproduce

herbie shell --seed 2019120 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))