Average Error: 58.1 → 0.9
Time: 15.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(\log \left(e^{\frac{-1}{3} \cdot {im}^{3}}\right) - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\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(\log \left(e^{\frac{-1}{3} \cdot {im}^{3}}\right) - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)
double f(double re, double im) {
        double r211506 = 0.5;
        double r211507 = re;
        double r211508 = cos(r211507);
        double r211509 = r211506 * r211508;
        double r211510 = 0.0;
        double r211511 = im;
        double r211512 = r211510 - r211511;
        double r211513 = exp(r211512);
        double r211514 = exp(r211511);
        double r211515 = r211513 - r211514;
        double r211516 = r211509 * r211515;
        return r211516;
}

double f(double re, double im) {
        double r211517 = 0.5;
        double r211518 = re;
        double r211519 = cos(r211518);
        double r211520 = r211517 * r211519;
        double r211521 = -0.3333333333333333;
        double r211522 = im;
        double r211523 = 3.0;
        double r211524 = pow(r211522, r211523);
        double r211525 = r211521 * r211524;
        double r211526 = exp(r211525);
        double r211527 = log(r211526);
        double r211528 = 0.016666666666666666;
        double r211529 = 5.0;
        double r211530 = pow(r211522, r211529);
        double r211531 = r211528 * r211530;
        double r211532 = 2.0;
        double r211533 = r211532 * r211522;
        double r211534 = r211531 + r211533;
        double r211535 = r211527 - r211534;
        double r211536 = r211520 * r211535;
        return r211536;
}

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 add-log-exp0.9

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

    \[\leadsto \left(0.5 \cdot \cos re\right) \cdot \left(\log \left(e^{\frac{-1}{3} \cdot {im}^{3}}\right) - \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\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))))