Average Error: 0.0 → 0.0
Time: 11.9s
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 r786824 = x;
        double r786825 = exp(r786824);
        double r786826 = -r786824;
        double r786827 = exp(r786826);
        double r786828 = r786825 + r786827;
        double r786829 = 2.0;
        double r786830 = r786828 / r786829;
        double r786831 = y;
        double r786832 = cos(r786831);
        double r786833 = r786830 * r786832;
        double r786834 = r786825 - r786827;
        double r786835 = r786834 / r786829;
        double r786836 = sin(r786831);
        double r786837 = r786835 * r786836;
        double r786838 = /* ERROR: no complex support in C */;
        double r786839 = /* ERROR: no complex support in C */;
        return r786839;
}

double f(double x, double y) {
        double r786840 = x;
        double r786841 = exp(r786840);
        double r786842 = y;
        double r786843 = cos(r786842);
        double r786844 = r786843 / r786841;
        double r786845 = fma(r786841, r786843, r786844);
        double r786846 = 2.0;
        double r786847 = r786845 / r786846;
        return r786847;
}

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 2019164 +o rules:numerics
(FPCore (x y)
  :name "Euler formula real part (p55)"
  (re (complex (* (/ (+ (exp x) (exp (- x))) 2) (cos y)) (* (/ (- (exp x) (exp (- x))) 2) (sin y)))))