Average Error: 43.7 → 0.7
Time: 24.6s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\sin re \cdot \left(\left(-{im}^{3} \cdot 0.1666666666666666574148081281236954964697\right) - \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\sin re \cdot \left(\left(-{im}^{3} \cdot 0.1666666666666666574148081281236954964697\right) - \left(0.008333333333333333217685101601546193705872 \cdot {im}^{5} + 1 \cdot im\right)\right)
double f(double re, double im) {
        double r265154 = 0.5;
        double r265155 = re;
        double r265156 = sin(r265155);
        double r265157 = r265154 * r265156;
        double r265158 = im;
        double r265159 = -r265158;
        double r265160 = exp(r265159);
        double r265161 = exp(r265158);
        double r265162 = r265160 - r265161;
        double r265163 = r265157 * r265162;
        return r265163;
}

double f(double re, double im) {
        double r265164 = re;
        double r265165 = sin(r265164);
        double r265166 = im;
        double r265167 = 3.0;
        double r265168 = pow(r265166, r265167);
        double r265169 = 0.16666666666666666;
        double r265170 = r265168 * r265169;
        double r265171 = -r265170;
        double r265172 = 0.008333333333333333;
        double r265173 = 5.0;
        double r265174 = pow(r265166, r265173);
        double r265175 = r265172 * r265174;
        double r265176 = 1.0;
        double r265177 = r265176 * r265166;
        double r265178 = r265175 + r265177;
        double r265179 = r265171 - r265178;
        double r265180 = r265165 * r265179;
        return r265180;
}

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.7
Target0.3
Herbie0.7
\[\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.7

    \[\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. 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)}\]
  4. Final simplification0.7

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

Reproduce

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

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

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