Average Error: 43.8 → 0.8
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(-\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 r338010 = 0.5;
        double r338011 = re;
        double r338012 = sin(r338011);
        double r338013 = r338010 * r338012;
        double r338014 = im;
        double r338015 = -r338014;
        double r338016 = exp(r338015);
        double r338017 = exp(r338014);
        double r338018 = r338016 - r338017;
        double r338019 = r338013 * r338018;
        return r338019;
}

double f(double re, double im) {
        double r338020 = 0.5;
        double r338021 = re;
        double r338022 = sin(r338021);
        double r338023 = r338020 * r338022;
        double r338024 = 0.3333333333333333;
        double r338025 = im;
        double r338026 = 3.0;
        double r338027 = pow(r338025, r338026);
        double r338028 = r338024 * r338027;
        double r338029 = 0.016666666666666666;
        double r338030 = 5.0;
        double r338031 = pow(r338025, r338030);
        double r338032 = r338029 * r338031;
        double r338033 = cbrt(r338032);
        double r338034 = r338033 * r338033;
        double r338035 = r338034 * r338033;
        double r338036 = 2.0;
        double r338037 = r338036 * r338025;
        double r338038 = r338035 + r338037;
        double r338039 = r338028 + r338038;
        double r338040 = -r338039;
        double r338041 = r338023 * r338040;
        return r338041;
}

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))))