Average Error: 0.0 → 0.0
Time: 10.5s
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 r864799 = x;
        double r864800 = exp(r864799);
        double r864801 = -r864799;
        double r864802 = exp(r864801);
        double r864803 = r864800 + r864802;
        double r864804 = 2.0;
        double r864805 = r864803 / r864804;
        double r864806 = y;
        double r864807 = cos(r864806);
        double r864808 = r864805 * r864807;
        double r864809 = r864800 - r864802;
        double r864810 = r864809 / r864804;
        double r864811 = sin(r864806);
        double r864812 = r864810 * r864811;
        double r864813 = /* ERROR: no complex support in C */;
        double r864814 = /* ERROR: no complex support in C */;
        return r864814;
}

double f(double x, double y) {
        double r864815 = x;
        double r864816 = exp(r864815);
        double r864817 = y;
        double r864818 = cos(r864817);
        double r864819 = r864818 / r864816;
        double r864820 = fma(r864816, r864818, r864819);
        double r864821 = 2.0;
        double r864822 = r864820 / r864821;
        return r864822;
}

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 2019134 +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)))))