Average Error: 43.5 → 0.8
Time: 18.0s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\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)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\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)
double f(double re, double im) {
        double r343211 = 0.5;
        double r343212 = re;
        double r343213 = sin(r343212);
        double r343214 = r343211 * r343213;
        double r343215 = im;
        double r343216 = -r343215;
        double r343217 = exp(r343216);
        double r343218 = exp(r343215);
        double r343219 = r343217 - r343218;
        double r343220 = r343214 * r343219;
        return r343220;
}

double f(double re, double im) {
        double r343221 = 0.16666666666666666;
        double r343222 = re;
        double r343223 = sin(r343222);
        double r343224 = im;
        double r343225 = 3.0;
        double r343226 = pow(r343224, r343225);
        double r343227 = r343223 * r343226;
        double r343228 = r343221 * r343227;
        double r343229 = -r343228;
        double r343230 = 0.008333333333333333;
        double r343231 = 5.0;
        double r343232 = pow(r343224, r343231);
        double r343233 = r343230 * r343232;
        double r343234 = 1.0;
        double r343235 = r343234 * r343224;
        double r343236 = r343233 + r343235;
        double r343237 = r343223 * r343236;
        double r343238 = r343229 - r343237;
        return r343238;
}

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.5
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.5

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

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

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

    \[\leadsto \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)\]

Reproduce

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