Average Error: 58.0 → 0.7
Time: 29.2s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)\]
\[\left(\left({im}^{5} \cdot \frac{-1}{60} - \left(2 + \left(im \cdot \frac{1}{3}\right) \cdot im\right) \cdot im\right) \cdot 0.5\right) \cdot \cos re\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0 - im} - e^{im}\right)
\left(\left({im}^{5} \cdot \frac{-1}{60} - \left(2 + \left(im \cdot \frac{1}{3}\right) \cdot im\right) \cdot im\right) \cdot 0.5\right) \cdot \cos re
double f(double re, double im) {
        double r8085211 = 0.5;
        double r8085212 = re;
        double r8085213 = cos(r8085212);
        double r8085214 = r8085211 * r8085213;
        double r8085215 = 0.0;
        double r8085216 = im;
        double r8085217 = r8085215 - r8085216;
        double r8085218 = exp(r8085217);
        double r8085219 = exp(r8085216);
        double r8085220 = r8085218 - r8085219;
        double r8085221 = r8085214 * r8085220;
        return r8085221;
}

double f(double re, double im) {
        double r8085222 = im;
        double r8085223 = 5.0;
        double r8085224 = pow(r8085222, r8085223);
        double r8085225 = -0.016666666666666666;
        double r8085226 = r8085224 * r8085225;
        double r8085227 = 2.0;
        double r8085228 = 0.3333333333333333;
        double r8085229 = r8085222 * r8085228;
        double r8085230 = r8085229 * r8085222;
        double r8085231 = r8085227 + r8085230;
        double r8085232 = r8085231 * r8085222;
        double r8085233 = r8085226 - r8085232;
        double r8085234 = 0.5;
        double r8085235 = r8085233 * r8085234;
        double r8085236 = re;
        double r8085237 = cos(r8085236);
        double r8085238 = r8085235 * r8085237;
        return r8085238;
}

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

Derivation

  1. Initial program 58.0

    \[\left(0.5 \cdot \cos re\right) \cdot \left(e^{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(\left({im}^{5} \cdot \frac{-1}{60} - \left(im + im\right)\right) - \left(im \cdot im\right) \cdot \left(im \cdot \frac{1}{3}\right)\right)}\]
  4. Using strategy rm
  5. Applied *-commutative0.7

    \[\leadsto \color{blue}{\left(\left({im}^{5} \cdot \frac{-1}{60} - \left(im + im\right)\right) - \left(im \cdot im\right) \cdot \left(im \cdot \frac{1}{3}\right)\right) \cdot \left(0.5 \cdot \cos re\right)}\]
  6. Using strategy rm
  7. Applied associate-*r*0.7

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

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

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (cos re) (+ (+ im (* (* (* 1/6 im) im) im)) (* (* (* (* (* 1/120 im) im) im) im) im)))) (* (* 0.5 (cos re)) (- (exp (- 0 im)) (exp im))))

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