Average Error: 0.0 → 0.0
Time: 30.5s
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 r1161459 = x;
        double r1161460 = exp(r1161459);
        double r1161461 = -r1161459;
        double r1161462 = exp(r1161461);
        double r1161463 = r1161460 + r1161462;
        double r1161464 = 2.0;
        double r1161465 = r1161463 / r1161464;
        double r1161466 = y;
        double r1161467 = cos(r1161466);
        double r1161468 = r1161465 * r1161467;
        double r1161469 = r1161460 - r1161462;
        double r1161470 = r1161469 / r1161464;
        double r1161471 = sin(r1161466);
        double r1161472 = r1161470 * r1161471;
        double r1161473 = /* ERROR: no complex support in C */;
        double r1161474 = /* ERROR: no complex support in C */;
        return r1161474;
}

double f(double x, double y) {
        double r1161475 = y;
        double r1161476 = cos(r1161475);
        double r1161477 = x;
        double r1161478 = exp(r1161477);
        double r1161479 = r1161476 / r1161478;
        double r1161480 = fma(r1161476, r1161478, r1161479);
        double r1161481 = 2.0;
        double r1161482 = r1161480 / r1161481;
        return r1161482;
}

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