Average Error: 43.5 → 0.8
Time: 8.2s
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 r230890 = 0.5;
        double r230891 = re;
        double r230892 = sin(r230891);
        double r230893 = r230890 * r230892;
        double r230894 = im;
        double r230895 = -r230894;
        double r230896 = exp(r230895);
        double r230897 = exp(r230894);
        double r230898 = r230896 - r230897;
        double r230899 = r230893 * r230898;
        return r230899;
}

double f(double re, double im) {
        double r230900 = 0.5;
        double r230901 = re;
        double r230902 = sin(r230901);
        double r230903 = r230900 * r230902;
        double r230904 = 0.3333333333333333;
        double r230905 = im;
        double r230906 = 3.0;
        double r230907 = pow(r230905, r230906);
        double r230908 = r230904 * r230907;
        double r230909 = 0.016666666666666666;
        double r230910 = 5.0;
        double r230911 = pow(r230905, r230910);
        double r230912 = r230909 * r230911;
        double r230913 = cbrt(r230912);
        double r230914 = r230913 * r230913;
        double r230915 = r230914 * r230913;
        double r230916 = 2.0;
        double r230917 = r230916 * r230905;
        double r230918 = r230915 + r230917;
        double r230919 = r230908 + r230918;
        double r230920 = -r230919;
        double r230921 = r230903 * r230920;
        return r230921;
}

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.166666666666666657 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.00833333333333333322 \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. 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 2020060 
(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))))