Average Error: 0.0 → 0.0
Time: 18.0s
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 r1126217 = x;
        double r1126218 = exp(r1126217);
        double r1126219 = -r1126217;
        double r1126220 = exp(r1126219);
        double r1126221 = r1126218 + r1126220;
        double r1126222 = 2.0;
        double r1126223 = r1126221 / r1126222;
        double r1126224 = y;
        double r1126225 = cos(r1126224);
        double r1126226 = r1126223 * r1126225;
        double r1126227 = r1126218 - r1126220;
        double r1126228 = r1126227 / r1126222;
        double r1126229 = sin(r1126224);
        double r1126230 = r1126228 * r1126229;
        double r1126231 = /* ERROR: no complex support in C */;
        double r1126232 = /* ERROR: no complex support in C */;
        return r1126232;
}

double f(double x, double y) {
        double r1126233 = x;
        double r1126234 = exp(r1126233);
        double r1126235 = y;
        double r1126236 = cos(r1126235);
        double r1126237 = r1126236 / r1126234;
        double r1126238 = fma(r1126234, r1126236, r1126237);
        double r1126239 = 2.0;
        double r1126240 = r1126238 / r1126239;
        return r1126240;
}

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