Average Error: 0.0 → 0.0
Time: 21.2s
Precision: 64
\[\Re(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
\[\frac{\mathsf{fma}\left(e^{x}, \cos y, \frac{\cos y}{e^{x}}\right)}{2}\]
\Re(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))
\frac{\mathsf{fma}\left(e^{x}, \cos y, \frac{\cos y}{e^{x}}\right)}{2}
double f(double x, double y) {
        double r1487867 = x;
        double r1487868 = exp(r1487867);
        double r1487869 = -r1487867;
        double r1487870 = exp(r1487869);
        double r1487871 = r1487868 + r1487870;
        double r1487872 = 2.0;
        double r1487873 = r1487871 / r1487872;
        double r1487874 = y;
        double r1487875 = cos(r1487874);
        double r1487876 = r1487873 * r1487875;
        double r1487877 = r1487868 - r1487870;
        double r1487878 = r1487877 / r1487872;
        double r1487879 = sin(r1487874);
        double r1487880 = r1487878 * r1487879;
        double r1487881 = /* ERROR: no complex support in C */;
        double r1487882 = /* ERROR: no complex support in C */;
        return r1487882;
}

double f(double x, double y) {
        double r1487883 = x;
        double r1487884 = exp(r1487883);
        double r1487885 = y;
        double r1487886 = cos(r1487885);
        double r1487887 = r1487886 / r1487884;
        double r1487888 = fma(r1487884, r1487886, r1487887);
        double r1487889 = 2.0;
        double r1487890 = r1487888 / r1487889;
        return r1487890;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 0.0

    \[\Re(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{x}, \cos y, \frac{\cos y}{e^{x}}\right)}{2}}\]
  3. Final simplification0.0

    \[\leadsto \frac{\mathsf{fma}\left(e^{x}, \cos y, \frac{\cos y}{e^{x}}\right)}{2}\]

Reproduce

herbie shell --seed 2019172 +o rules:numerics
(FPCore (x y)
  :name "Euler formula real part (p55)"
  (re (complex (* (/ (+ (exp x) (exp (- x))) 2.0) (cos y)) (* (/ (- (exp x) (exp (- x))) 2.0) (sin y)))))