Average Error: 58.0 → 0.8
Time: 7.8s
Precision: 64
\[\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)\]
\[0.5 \cdot \left(\cos re \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\right)\]
\left(0.5 \cdot \cos re\right) \cdot \left(e^{0.0 - im} - e^{im}\right)
0.5 \cdot \left(\cos re \cdot \left(-\left(\frac{1}{3} \cdot {im}^{3} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\right)
double f(double re, double im) {
        double r262829 = 0.5;
        double r262830 = re;
        double r262831 = cos(r262830);
        double r262832 = r262829 * r262831;
        double r262833 = 0.0;
        double r262834 = im;
        double r262835 = r262833 - r262834;
        double r262836 = exp(r262835);
        double r262837 = exp(r262834);
        double r262838 = r262836 - r262837;
        double r262839 = r262832 * r262838;
        return r262839;
}

double f(double re, double im) {
        double r262840 = 0.5;
        double r262841 = re;
        double r262842 = cos(r262841);
        double r262843 = 0.3333333333333333;
        double r262844 = im;
        double r262845 = 3.0;
        double r262846 = pow(r262844, r262845);
        double r262847 = r262843 * r262846;
        double r262848 = 0.016666666666666666;
        double r262849 = 5.0;
        double r262850 = pow(r262844, r262849);
        double r262851 = r262848 * r262850;
        double r262852 = 2.0;
        double r262853 = r262852 * r262844;
        double r262854 = r262851 + r262853;
        double r262855 = r262847 + r262854;
        double r262856 = -r262855;
        double r262857 = r262842 * r262856;
        double r262858 = r262840 * r262857;
        return r262858;
}

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.8
\[\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.0

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

    \[\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. Using strategy rm
  4. Applied associate-*l*0.8

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

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

Reproduce

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