Average Error: 0.0 → 0.0
Time: 10.1s
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 r1212489 = x;
        double r1212490 = exp(r1212489);
        double r1212491 = -r1212489;
        double r1212492 = exp(r1212491);
        double r1212493 = r1212490 + r1212492;
        double r1212494 = 2.0;
        double r1212495 = r1212493 / r1212494;
        double r1212496 = y;
        double r1212497 = cos(r1212496);
        double r1212498 = r1212495 * r1212497;
        double r1212499 = r1212490 - r1212492;
        double r1212500 = r1212499 / r1212494;
        double r1212501 = sin(r1212496);
        double r1212502 = r1212500 * r1212501;
        double r1212503 = /* ERROR: no complex support in C */;
        double r1212504 = /* ERROR: no complex support in C */;
        return r1212504;
}

double f(double x, double y) {
        double r1212505 = x;
        double r1212506 = exp(r1212505);
        double r1212507 = y;
        double r1212508 = cos(r1212507);
        double r1212509 = r1212508 / r1212506;
        double r1212510 = fma(r1212506, r1212508, r1212509);
        double r1212511 = 2.0;
        double r1212512 = r1212510 / r1212511;
        return r1212512;
}

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