Average Error: 58.1 → 0.9
Time: 22.4s
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(\log \left(e^{\frac{-1}{3} \cdot {im}^{3}}\right) - \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(\log \left(e^{\frac{-1}{3} \cdot {im}^{3}}\right) - \frac{1}{60} \cdot {im}^{5}\right) - 2 \cdot im\right)
double f(double re, double im) {
        double r179169 = 0.5;
        double r179170 = re;
        double r179171 = cos(r179170);
        double r179172 = r179169 * r179171;
        double r179173 = 0.0;
        double r179174 = im;
        double r179175 = r179173 - r179174;
        double r179176 = exp(r179175);
        double r179177 = exp(r179174);
        double r179178 = r179176 - r179177;
        double r179179 = r179172 * r179178;
        return r179179;
}

double f(double re, double im) {
        double r179180 = 0.5;
        double r179181 = re;
        double r179182 = cos(r179181);
        double r179183 = r179180 * r179182;
        double r179184 = -0.3333333333333333;
        double r179185 = im;
        double r179186 = 3.0;
        double r179187 = pow(r179185, r179186);
        double r179188 = r179184 * r179187;
        double r179189 = exp(r179188);
        double r179190 = log(r179189);
        double r179191 = 0.016666666666666666;
        double r179192 = 5.0;
        double r179193 = pow(r179185, r179192);
        double r179194 = r179191 * r179193;
        double r179195 = r179190 - r179194;
        double r179196 = 2.0;
        double r179197 = r179196 * r179185;
        double r179198 = r179195 - r179197;
        double r179199 = r179183 * r179198;
        return r179199;
}

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.9
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\cos re \cdot \left(\left(im + \left(\left(0.166666666666666657 \cdot im\right) \cdot im\right) \cdot im\right) + \left(\left(\left(\left(0.00833333333333333322 \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. Using strategy rm
  7. Applied add-log-exp0.9

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

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

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (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))))