Average Error: 43.2 → 0.8
Time: 34.0s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\frac{-{im}^{3}}{3} - 2 \cdot im\right) - \frac{{im}^{5}}{60}\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\left(\frac{1}{2} \cdot \sin re\right) \cdot \left(\left(\frac{-{im}^{3}}{3} - 2 \cdot im\right) - \frac{{im}^{5}}{60}\right)
double f(double re, double im) {
        double r197225 = 0.5;
        double r197226 = re;
        double r197227 = sin(r197226);
        double r197228 = r197225 * r197227;
        double r197229 = im;
        double r197230 = -r197229;
        double r197231 = exp(r197230);
        double r197232 = exp(r197229);
        double r197233 = r197231 - r197232;
        double r197234 = r197228 * r197233;
        return r197234;
}

double f(double re, double im) {
        double r197235 = 1.0;
        double r197236 = 2.0;
        double r197237 = r197235 / r197236;
        double r197238 = re;
        double r197239 = sin(r197238);
        double r197240 = r197237 * r197239;
        double r197241 = im;
        double r197242 = 3.0;
        double r197243 = pow(r197241, r197242);
        double r197244 = -r197243;
        double r197245 = r197244 / r197242;
        double r197246 = 2.0;
        double r197247 = r197246 * r197241;
        double r197248 = r197245 - r197247;
        double r197249 = 5.0;
        double r197250 = pow(r197241, r197249);
        double r197251 = 60.0;
        double r197252 = r197250 / r197251;
        double r197253 = r197248 - r197252;
        double r197254 = r197240 * r197253;
        return r197254;
}

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

    \[\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.8

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

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

Reproduce

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