Average Error: 58.0 → 0.7
Time: 28.7s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(\left(\frac{-1}{3} \cdot {im}^{3} - \left(im + im\right)\right) - \frac{1}{60} \cdot {im}^{5}\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(\left(\frac{-1}{3} \cdot {im}^{3} - \left(im + im\right)\right) - \frac{1}{60} \cdot {im}^{5}\right) \cdot \left(0.5 \cdot \cos re\right)
double f(double re, double im) {
        double r213211 = 0.5;
        double r213212 = re;
        double r213213 = cos(r213212);
        double r213214 = r213211 * r213213;
        double r213215 = 0.0;
        double r213216 = im;
        double r213217 = r213215 - r213216;
        double r213218 = exp(r213217);
        double r213219 = exp(r213216);
        double r213220 = r213218 - r213219;
        double r213221 = r213214 * r213220;
        return r213221;
}

double f(double re, double im) {
        double r213222 = -0.3333333333333333;
        double r213223 = im;
        double r213224 = 3.0;
        double r213225 = pow(r213223, r213224);
        double r213226 = r213222 * r213225;
        double r213227 = r213223 + r213223;
        double r213228 = r213226 - r213227;
        double r213229 = 0.016666666666666666;
        double r213230 = 5.0;
        double r213231 = pow(r213223, r213230);
        double r213232 = r213229 * r213231;
        double r213233 = r213228 - r213232;
        double r213234 = 0.5;
        double r213235 = re;
        double r213236 = cos(r213235);
        double r213237 = r213234 * r213236;
        double r213238 = r213233 * r213237;
        return r213238;
}

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(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.0

    \[\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(\left({im}^{3} \cdot \frac{-1}{3} - \left(im + im\right)\right) - \frac{1}{60} \cdot {im}^{5}\right)}\]
  4. Final simplification0.7

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1.0) (- (* (cos re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 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))))