Average Error: 0.0 → 0.0
Time: 14.4s
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 r793048 = x;
        double r793049 = exp(r793048);
        double r793050 = -r793048;
        double r793051 = exp(r793050);
        double r793052 = r793049 + r793051;
        double r793053 = 2.0;
        double r793054 = r793052 / r793053;
        double r793055 = y;
        double r793056 = cos(r793055);
        double r793057 = r793054 * r793056;
        double r793058 = r793049 - r793051;
        double r793059 = r793058 / r793053;
        double r793060 = sin(r793055);
        double r793061 = r793059 * r793060;
        double r793062 = /* ERROR: no complex support in C */;
        double r793063 = /* ERROR: no complex support in C */;
        return r793063;
}

double f(double x, double y) {
        double r793064 = y;
        double r793065 = cos(r793064);
        double r793066 = x;
        double r793067 = exp(r793066);
        double r793068 = r793065 / r793067;
        double r793069 = fma(r793065, r793067, r793068);
        double r793070 = 2.0;
        double r793071 = r793069 / r793070;
        return r793071;
}

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 2019139 +o rules:numerics
(FPCore (x y)
  :name "Euler formula real part (p55)"
  (re (complex (* (/ (+ (exp x) (exp (- x))) 2) (cos y)) (* (/ (- (exp x) (exp (- x))) 2) (sin y)))))