Average Error: 43.6 → 0.7
Time: 23.7s
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({im}^{5} \cdot \frac{-1}{60} + \frac{-1}{3} \cdot {im}^{3}\right) - 2 \cdot im\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({im}^{5} \cdot \frac{-1}{60} + \frac{-1}{3} \cdot {im}^{3}\right) - 2 \cdot im\right)
double f(double re, double im) {
        double r205018 = 0.5;
        double r205019 = re;
        double r205020 = sin(r205019);
        double r205021 = r205018 * r205020;
        double r205022 = im;
        double r205023 = -r205022;
        double r205024 = exp(r205023);
        double r205025 = exp(r205022);
        double r205026 = r205024 - r205025;
        double r205027 = r205021 * r205026;
        return r205027;
}

double f(double re, double im) {
        double r205028 = 0.5;
        double r205029 = re;
        double r205030 = sin(r205029);
        double r205031 = r205028 * r205030;
        double r205032 = im;
        double r205033 = 5.0;
        double r205034 = pow(r205032, r205033);
        double r205035 = -0.016666666666666666;
        double r205036 = r205034 * r205035;
        double r205037 = -0.3333333333333333;
        double r205038 = 3.0;
        double r205039 = pow(r205032, r205038);
        double r205040 = r205037 * r205039;
        double r205041 = r205036 + r205040;
        double r205042 = 2.0;
        double r205043 = r205042 * r205032;
        double r205044 = r205041 - r205043;
        double r205045 = r205031 * r205044;
        return r205045;
}

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

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

    \[\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. Using strategy rm
  5. Applied associate--r+0.7

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

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

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

Reproduce

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