Average Error: 0.0 → 0.0
Time: 6.7s
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(\cos y, e^{x}, \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(\cos y, e^{x}, \frac{\cos y}{e^{x}}\right)}{2}
double f(double x, double y) {
        double r228748 = x;
        double r228749 = exp(r228748);
        double r228750 = -r228748;
        double r228751 = exp(r228750);
        double r228752 = r228749 + r228751;
        double r228753 = 2.0;
        double r228754 = r228752 / r228753;
        double r228755 = y;
        double r228756 = cos(r228755);
        double r228757 = r228754 * r228756;
        double r228758 = r228749 - r228751;
        double r228759 = r228758 / r228753;
        double r228760 = sin(r228755);
        double r228761 = r228759 * r228760;
        double r228762 = /* ERROR: no complex support in C */;
        double r228763 = /* ERROR: no complex support in C */;
        return r228763;
}

double f(double x, double y) {
        double r228764 = y;
        double r228765 = cos(r228764);
        double r228766 = x;
        double r228767 = exp(r228766);
        double r228768 = r228765 / r228767;
        double r228769 = fma(r228765, r228767, r228768);
        double r228770 = 2.0;
        double r228771 = r228769 / r228770;
        return r228771;
}

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(\cos y, e^{x}, \frac{\cos y}{e^{x}}\right)}{2}}\]
  3. Final simplification0.0

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

Reproduce

herbie shell --seed 2019154 +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)))))