Average Error: 43.2 → 1.1
Time: 27.8s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(-0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\sin re \cdot {im}^{3}}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\left(-0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\sin re \cdot {im}^{3}}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)
double f(double re, double im) {
        double r250845 = 0.5;
        double r250846 = re;
        double r250847 = sin(r250846);
        double r250848 = r250845 * r250847;
        double r250849 = im;
        double r250850 = -r250849;
        double r250851 = exp(r250850);
        double r250852 = exp(r250849);
        double r250853 = r250851 - r250852;
        double r250854 = r250848 * r250853;
        return r250854;
}

double f(double re, double im) {
        double r250855 = 0.16666666666666666;
        double r250856 = re;
        double r250857 = sin(r250856);
        double r250858 = im;
        double r250859 = 3.0;
        double r250860 = pow(r250858, r250859);
        double r250861 = r250857 * r250860;
        double r250862 = exp(r250861);
        double r250863 = log(r250862);
        double r250864 = r250855 * r250863;
        double r250865 = -r250864;
        double r250866 = 0.008333333333333333;
        double r250867 = 5.0;
        double r250868 = pow(r250858, r250867);
        double r250869 = r250866 * r250868;
        double r250870 = 1.0;
        double r250871 = r250870 * r250858;
        double r250872 = r250869 + r250871;
        double r250873 = r250857 * r250872;
        double r250874 = r250865 - r250873;
        return r250874;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original43.2
Target0.3
Herbie1.1
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 43.2

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.7

    \[\leadsto \left(0.5 \cdot \sin 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 \sin re\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {im}^{3} - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)}\]
  4. Taylor expanded around inf 0.7

    \[\leadsto \color{blue}{-\left(0.1666666666666666574148081281236954964697 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.008333333333333333217685101601546193705872 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)}\]
  5. Simplified0.7

    \[\leadsto \color{blue}{\left(-0.1666666666666666574148081281236954964697 \cdot \left(\sin re \cdot {im}^{3}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)}\]
  6. Using strategy rm
  7. Applied add-log-exp1.1

    \[\leadsto \left(-0.1666666666666666574148081281236954964697 \cdot \color{blue}{\log \left(e^{\sin re \cdot {im}^{3}}\right)}\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\]
  8. Final simplification1.1

    \[\leadsto \left(-0.1666666666666666574148081281236954964697 \cdot \log \left(e^{\sin re \cdot {im}^{3}}\right)\right) - \sin re \cdot \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\]

Reproduce

herbie shell --seed 2019323 
(FPCore (re im)
  :name "math.cos on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))