Average Error: 58.1 → 0.7
Time: 27.2s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[\left(0.5 \cdot \cos re\right) \cdot \left(\left(\frac{-1}{3} \cdot {im}^{3} - \frac{1}{60} \cdot {im}^{5}\right) - 2 \cdot im\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
\left(0.5 \cdot \cos re\right) \cdot \left(\left(\frac{-1}{3} \cdot {im}^{3} - \frac{1}{60} \cdot {im}^{5}\right) - 2 \cdot im\right)
double f(double re, double im) {
        double r152851 = 0.5;
        double r152852 = re;
        double r152853 = cos(r152852);
        double r152854 = r152851 * r152853;
        double r152855 = 0.0;
        double r152856 = im;
        double r152857 = r152855 - r152856;
        double r152858 = exp(r152857);
        double r152859 = exp(r152856);
        double r152860 = r152858 - r152859;
        double r152861 = r152854 * r152860;
        return r152861;
}

double f(double re, double im) {
        double r152862 = 0.5;
        double r152863 = re;
        double r152864 = cos(r152863);
        double r152865 = r152862 * r152864;
        double r152866 = -0.3333333333333333;
        double r152867 = im;
        double r152868 = 3.0;
        double r152869 = pow(r152867, r152868);
        double r152870 = r152866 * r152869;
        double r152871 = 0.016666666666666666;
        double r152872 = 5.0;
        double r152873 = pow(r152867, r152872);
        double r152874 = r152871 * r152873;
        double r152875 = r152870 - r152874;
        double r152876 = 2.0;
        double r152877 = r152876 * r152867;
        double r152878 = r152875 - r152877;
        double r152879 = r152865 * r152878;
        return r152879;
}

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.1
Target0.2
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.1

    \[\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 associate--r+0.7

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

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

Reproduce

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