Average Error: 58.2 → 0.7
Time: 29.7s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(\frac{-1}{3} \cdot {im}^{3}\right) \cdot \left(0.5 \cdot \cos re\right) + \left({im}^{5} \cdot \frac{-1}{60} + -2 \cdot im\right) \cdot \left(0.5 \cdot \cos re\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(\frac{-1}{3} \cdot {im}^{3}\right) \cdot \left(0.5 \cdot \cos re\right) + \left({im}^{5} \cdot \frac{-1}{60} + -2 \cdot im\right) \cdot \left(0.5 \cdot \cos re\right)
double f(double re, double im) {
        double r227235 = 0.5;
        double r227236 = re;
        double r227237 = cos(r227236);
        double r227238 = r227235 * r227237;
        double r227239 = 0.0;
        double r227240 = im;
        double r227241 = r227239 - r227240;
        double r227242 = exp(r227241);
        double r227243 = exp(r227240);
        double r227244 = r227242 - r227243;
        double r227245 = r227238 * r227244;
        return r227245;
}

double f(double re, double im) {
        double r227246 = -0.3333333333333333;
        double r227247 = im;
        double r227248 = 3.0;
        double r227249 = pow(r227247, r227248);
        double r227250 = r227246 * r227249;
        double r227251 = 0.5;
        double r227252 = re;
        double r227253 = cos(r227252);
        double r227254 = r227251 * r227253;
        double r227255 = r227250 * r227254;
        double r227256 = 5.0;
        double r227257 = pow(r227247, r227256);
        double r227258 = -0.016666666666666666;
        double r227259 = r227257 * r227258;
        double r227260 = -2.0;
        double r227261 = r227260 * r227247;
        double r227262 = r227259 + r227261;
        double r227263 = r227262 * r227254;
        double r227264 = r227255 + r227263;
        return r227264;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original58.2
Target0.3
Herbie0.7
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos 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 \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 58.2

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

    \[\leadsto \left(0.5 \cdot \cos 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 \cos 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 sub-neg0.7

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \color{blue}{\left(\frac{-1}{3} \cdot {im}^{3} + \left(-\left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)}\]
  6. Applied distribute-lft-in0.7

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

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

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

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

Reproduce

herbie shell --seed 2019212 
(FPCore (re im)
  :name "math.sin on complex, imaginary part"
  :precision binary64

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 0.166666666666666657 im) im) im)) (* (* (* (* (* 0.00833333333333333322 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))

  (* (* 0.5 (cos re)) (- (exp (- 0.0 im)) (exp im))))