Average Error: 0.0 → 0.0
Time: 15.3s
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 r1016542 = x;
        double r1016543 = exp(r1016542);
        double r1016544 = -r1016542;
        double r1016545 = exp(r1016544);
        double r1016546 = r1016543 + r1016545;
        double r1016547 = 2.0;
        double r1016548 = r1016546 / r1016547;
        double r1016549 = y;
        double r1016550 = cos(r1016549);
        double r1016551 = r1016548 * r1016550;
        double r1016552 = r1016543 - r1016545;
        double r1016553 = r1016552 / r1016547;
        double r1016554 = sin(r1016549);
        double r1016555 = r1016553 * r1016554;
        double r1016556 = /* ERROR: no complex support in C */;
        double r1016557 = /* ERROR: no complex support in C */;
        return r1016557;
}

double f(double x, double y) {
        double r1016558 = y;
        double r1016559 = cos(r1016558);
        double r1016560 = x;
        double r1016561 = exp(r1016560);
        double r1016562 = r1016559 / r1016561;
        double r1016563 = fma(r1016559, r1016561, r1016562);
        double r1016564 = 2.0;
        double r1016565 = r1016563 / r1016564;
        return r1016565;
}

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