Average Error: 0.0 → 0.0
Time: 17.4s
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 r1327579 = x;
        double r1327580 = exp(r1327579);
        double r1327581 = -r1327579;
        double r1327582 = exp(r1327581);
        double r1327583 = r1327580 + r1327582;
        double r1327584 = 2.0;
        double r1327585 = r1327583 / r1327584;
        double r1327586 = y;
        double r1327587 = cos(r1327586);
        double r1327588 = r1327585 * r1327587;
        double r1327589 = r1327580 - r1327582;
        double r1327590 = r1327589 / r1327584;
        double r1327591 = sin(r1327586);
        double r1327592 = r1327590 * r1327591;
        double r1327593 = /* ERROR: no complex support in C */;
        double r1327594 = /* ERROR: no complex support in C */;
        return r1327594;
}

double f(double x, double y) {
        double r1327595 = x;
        double r1327596 = exp(r1327595);
        double r1327597 = y;
        double r1327598 = cos(r1327597);
        double r1327599 = r1327598 / r1327596;
        double r1327600 = fma(r1327596, r1327598, r1327599);
        double r1327601 = 2.0;
        double r1327602 = r1327600 / r1327601;
        return r1327602;
}

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