Average Error: 0.0 → 0.0
Time: 8.8s
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 r1538970 = x;
        double r1538971 = exp(r1538970);
        double r1538972 = -r1538970;
        double r1538973 = exp(r1538972);
        double r1538974 = r1538971 + r1538973;
        double r1538975 = 2.0;
        double r1538976 = r1538974 / r1538975;
        double r1538977 = y;
        double r1538978 = cos(r1538977);
        double r1538979 = r1538976 * r1538978;
        double r1538980 = r1538971 - r1538973;
        double r1538981 = r1538980 / r1538975;
        double r1538982 = sin(r1538977);
        double r1538983 = r1538981 * r1538982;
        double r1538984 = /* ERROR: no complex support in C */;
        double r1538985 = /* ERROR: no complex support in C */;
        return r1538985;
}

double f(double x, double y) {
        double r1538986 = x;
        double r1538987 = exp(r1538986);
        double r1538988 = y;
        double r1538989 = cos(r1538988);
        double r1538990 = r1538989 / r1538987;
        double r1538991 = fma(r1538987, r1538989, r1538990);
        double r1538992 = 2.0;
        double r1538993 = r1538991 / r1538992;
        return r1538993;
}

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