Average Error: 58.0 → 0.9
Time: 9.8s
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) + \left(\log \left(e^{\frac{1}{60} \cdot {im}^{5}}\right) + 2 \cdot im\right)\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(-\left(\log \left(e^{\frac{1}{3} \cdot {im}^{3}}\right) + \left(\log \left(e^{\frac{1}{60} \cdot {im}^{5}}\right) + 2 \cdot im\right)\right)\right)
double f(double re, double im) {
        double r144854 = 0.5;
        double r144855 = re;
        double r144856 = cos(r144855);
        double r144857 = r144854 * r144856;
        double r144858 = 0.0;
        double r144859 = im;
        double r144860 = r144858 - r144859;
        double r144861 = exp(r144860);
        double r144862 = exp(r144859);
        double r144863 = r144861 - r144862;
        double r144864 = r144857 * r144863;
        return r144864;
}

double f(double re, double im) {
        double r144865 = 0.5;
        double r144866 = re;
        double r144867 = cos(r144866);
        double r144868 = r144865 * r144867;
        double r144869 = 0.3333333333333333;
        double r144870 = im;
        double r144871 = 3.0;
        double r144872 = pow(r144870, r144871);
        double r144873 = r144869 * r144872;
        double r144874 = exp(r144873);
        double r144875 = log(r144874);
        double r144876 = 0.016666666666666666;
        double r144877 = 5.0;
        double r144878 = pow(r144870, r144877);
        double r144879 = r144876 * r144878;
        double r144880 = exp(r144879);
        double r144881 = log(r144880);
        double r144882 = 2.0;
        double r144883 = r144882 * r144870;
        double r144884 = r144881 + r144883;
        double r144885 = r144875 + r144884;
        double r144886 = -r144885;
        double r144887 = r144868 * r144886;
        return r144887;
}

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.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.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 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)} + \left(\frac{1}{60} \cdot {im}^{5} + 2 \cdot im\right)\right)\right)\]
  5. Using strategy rm
  6. Applied add-log-exp0.9

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

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

Reproduce

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