Average Error: 43.4 → 0.8
Time: 8.0s
Precision: 64
\[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
\[-\left(0.166666666666666657 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.00833333333333333322 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)\]
\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)
-\left(0.166666666666666657 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.00833333333333333322 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)
double f(double re, double im) {
        double r211346 = 0.5;
        double r211347 = re;
        double r211348 = sin(r211347);
        double r211349 = r211346 * r211348;
        double r211350 = im;
        double r211351 = -r211350;
        double r211352 = exp(r211351);
        double r211353 = exp(r211350);
        double r211354 = r211352 - r211353;
        double r211355 = r211349 * r211354;
        return r211355;
}

double f(double re, double im) {
        double r211356 = 0.16666666666666666;
        double r211357 = re;
        double r211358 = sin(r211357);
        double r211359 = im;
        double r211360 = 3.0;
        double r211361 = pow(r211359, r211360);
        double r211362 = r211358 * r211361;
        double r211363 = r211356 * r211362;
        double r211364 = 1.0;
        double r211365 = r211358 * r211359;
        double r211366 = r211364 * r211365;
        double r211367 = 0.008333333333333333;
        double r211368 = 5.0;
        double r211369 = pow(r211359, r211368);
        double r211370 = r211358 * r211369;
        double r211371 = r211367 * r211370;
        double r211372 = r211366 + r211371;
        double r211373 = r211363 + r211372;
        double r211374 = -r211373;
        return r211374;
}

Error

Bits error versus re

Bits error versus im

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original43.4
Target0.3
Herbie0.8
\[\begin{array}{l} \mathbf{if}\;\left|im\right| \lt 1:\\ \;\;\;\;-\sin 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 \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\\ \end{array}\]

Derivation

  1. Initial program 43.4

    \[\left(0.5 \cdot \sin re\right) \cdot \left(e^{-im} - e^{im}\right)\]
  2. Taylor expanded around 0 0.8

    \[\leadsto \left(0.5 \cdot \sin 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. Taylor expanded around inf 0.8

    \[\leadsto \color{blue}{-\left(0.166666666666666657 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.00833333333333333322 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)}\]
  4. Final simplification0.8

    \[\leadsto -\left(0.166666666666666657 \cdot \left(\sin re \cdot {im}^{3}\right) + \left(1 \cdot \left(\sin re \cdot im\right) + 0.00833333333333333322 \cdot \left(\sin re \cdot {im}^{5}\right)\right)\right)\]

Reproduce

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

  :herbie-target
  (if (< (fabs im) 1) (- (* (sin re) (+ (+ im (* (* (* 0.16666666666666666 im) im) im)) (* (* (* (* (* 0.008333333333333333 im) im) im) im) im)))) (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))

  (* (* 0.5 (sin re)) (- (exp (- im)) (exp im))))