Average Error: 0.0 → 0.0
Time: 20.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(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 r4189110 = x;
        double r4189111 = exp(r4189110);
        double r4189112 = -r4189110;
        double r4189113 = exp(r4189112);
        double r4189114 = r4189111 + r4189113;
        double r4189115 = 2.0;
        double r4189116 = r4189114 / r4189115;
        double r4189117 = y;
        double r4189118 = cos(r4189117);
        double r4189119 = r4189116 * r4189118;
        double r4189120 = r4189111 - r4189113;
        double r4189121 = r4189120 / r4189115;
        double r4189122 = sin(r4189117);
        double r4189123 = r4189121 * r4189122;
        double r4189124 = /* ERROR: no complex support in C */;
        double r4189125 = /* ERROR: no complex support in C */;
        return r4189125;
}

double f(double x, double y) {
        double r4189126 = x;
        double r4189127 = exp(r4189126);
        double r4189128 = y;
        double r4189129 = cos(r4189128);
        double r4189130 = r4189129 / r4189127;
        double r4189131 = fma(r4189127, r4189129, r4189130);
        double r4189132 = 2.0;
        double r4189133 = r4189131 / r4189132;
        return r4189133;
}

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