Average Error: 43.7 → 0.7
Time: 9.5s
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 r181050 = 0.5;
        double r181051 = re;
        double r181052 = sin(r181051);
        double r181053 = r181050 * r181052;
        double r181054 = im;
        double r181055 = -r181054;
        double r181056 = exp(r181055);
        double r181057 = exp(r181054);
        double r181058 = r181056 - r181057;
        double r181059 = r181053 * r181058;
        return r181059;
}

double f(double re, double im) {
        double r181060 = 0.5;
        double r181061 = re;
        double r181062 = sin(r181061);
        double r181063 = r181060 * r181062;
        double r181064 = 0.3333333333333333;
        double r181065 = im;
        double r181066 = 3.0;
        double r181067 = pow(r181065, r181066);
        double r181068 = r181064 * r181067;
        double r181069 = 0.016666666666666666;
        double r181070 = 5.0;
        double r181071 = pow(r181065, r181070);
        double r181072 = r181069 * r181071;
        double r181073 = 2.0;
        double r181074 = r181073 * r181065;
        double r181075 = r181072 + r181074;
        double r181076 = r181068 + r181075;
        double r181077 = r181063 * r181076;
        double r181078 = -r181077;
        return r181078;
}

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

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.7

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

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

    \[\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 2020083 
(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))))