Average Error: 43.8 → 0.8
Time: 9.4s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[\left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\left(\sqrt[3]{\frac{1}{60} \cdot {im}^{5}} \cdot \sqrt[3]{\frac{1}{60} \cdot {im}^{5}}\right) \cdot \sqrt[3]{\frac{1}{60} \cdot {im}^{5}} + 2 \cdot im\right)\right)\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
\left(0.5 \cdot \sin re\right) \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\left(\sqrt[3]{\frac{1}{60} \cdot {im}^{5}} \cdot \sqrt[3]{\frac{1}{60} \cdot {im}^{5}}\right) \cdot \sqrt[3]{\frac{1}{60} \cdot {im}^{5}} + 2 \cdot im\right)\right)\right)
double f(double re, double im) {
        double r398230 = 0.5;
        double r398231 = re;
        double r398232 = sin(r398231);
        double r398233 = r398230 * r398232;
        double r398234 = im;
        double r398235 = -r398234;
        double r398236 = exp(r398235);
        double r398237 = exp(r398234);
        double r398238 = r398236 - r398237;
        double r398239 = r398233 * r398238;
        return r398239;
}

double f(double re, double im) {
        double r398240 = 0.5;
        double r398241 = re;
        double r398242 = sin(r398241);
        double r398243 = r398240 * r398242;
        double r398244 = 0.3333333333333333;
        double r398245 = im;
        double r398246 = 3.0;
        double r398247 = pow(r398245, r398246);
        double r398248 = r398244 * r398247;
        double r398249 = 0.016666666666666666;
        double r398250 = 5.0;
        double r398251 = pow(r398245, r398250);
        double r398252 = r398249 * r398251;
        double r398253 = cbrt(r398252);
        double r398254 = r398253 * r398253;
        double r398255 = r398254 * r398253;
        double r398256 = 2.0;
        double r398257 = r398256 * r398245;
        double r398258 = r398255 + r398257;
        double r398259 = r398248 + r398258;
        double r398260 = -r398259;
        double r398261 = r398243 * r398260;
        return r398261;
}

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

    \[\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. Using strategy rm
  4. Applied add-cube-cbrt0.8

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

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

Reproduce

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