Average Error: 0.0 → 0.0
Time: 48.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 r1161453 = x;
        double r1161454 = exp(r1161453);
        double r1161455 = -r1161453;
        double r1161456 = exp(r1161455);
        double r1161457 = r1161454 + r1161456;
        double r1161458 = 2.0;
        double r1161459 = r1161457 / r1161458;
        double r1161460 = y;
        double r1161461 = cos(r1161460);
        double r1161462 = r1161459 * r1161461;
        double r1161463 = r1161454 - r1161456;
        double r1161464 = r1161463 / r1161458;
        double r1161465 = sin(r1161460);
        double r1161466 = r1161464 * r1161465;
        double r1161467 = /* ERROR: no complex support in C */;
        double r1161468 = /* ERROR: no complex support in C */;
        return r1161468;
}

double f(double x, double y) {
        double r1161469 = y;
        double r1161470 = cos(r1161469);
        double r1161471 = x;
        double r1161472 = exp(r1161471);
        double r1161473 = r1161470 / r1161472;
        double r1161474 = fma(r1161470, r1161472, r1161473);
        double r1161475 = 2.0;
        double r1161476 = r1161474 / r1161475;
        return r1161476;
}

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