Average Error: 43.8 → 0.8
Time: 8.6s
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(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\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(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r157896 = 0.5;
        double r157897 = re;
        double r157898 = sin(r157897);
        double r157899 = r157896 * r157898;
        double r157900 = im;
        double r157901 = -r157900;
        double r157902 = exp(r157901);
        double r157903 = exp(r157900);
        double r157904 = r157902 - r157903;
        double r157905 = r157899 * r157904;
        return r157905;
}

double f(double re, double im) {
        double r157906 = 0.5;
        double r157907 = re;
        double r157908 = sin(r157907);
        double r157909 = r157906 * r157908;
        double r157910 = 0.3333333333333333;
        double r157911 = im;
        double r157912 = 3.0;
        double r157913 = pow(r157911, r157912);
        double r157914 = r157910 * r157913;
        double r157915 = 0.016666666666666666;
        double r157916 = 5.0;
        double r157917 = pow(r157911, r157916);
        double r157918 = r157915 * r157917;
        double r157919 = 2.0;
        double r157920 = r157919 * r157911;
        double r157921 = r157918 + r157920;
        double r157922 = r157914 + r157921;
        double r157923 = r157909 * r157922;
        double r157924 = -r157923;
        return r157924;
}

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 *-un-lft-identity0.8

    \[\leadsto \left(0.5 \cdot \sin re\right) \cdot \left(-\color{blue}{1 \cdot \left(\frac{1}{3} \cdot {im}^{3} + \left(\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(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\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))))