Average Error: 0.0 → 0.0
Time: 16.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(\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 r731096 = x;
        double r731097 = exp(r731096);
        double r731098 = -r731096;
        double r731099 = exp(r731098);
        double r731100 = r731097 + r731099;
        double r731101 = 2.0;
        double r731102 = r731100 / r731101;
        double r731103 = y;
        double r731104 = cos(r731103);
        double r731105 = r731102 * r731104;
        double r731106 = r731097 - r731099;
        double r731107 = r731106 / r731101;
        double r731108 = sin(r731103);
        double r731109 = r731107 * r731108;
        double r731110 = /* ERROR: no complex support in C */;
        double r731111 = /* ERROR: no complex support in C */;
        return r731111;
}

double f(double x, double y) {
        double r731112 = y;
        double r731113 = cos(r731112);
        double r731114 = x;
        double r731115 = exp(r731114);
        double r731116 = r731113 / r731115;
        double r731117 = fma(r731113, r731115, r731116);
        double r731118 = 2.0;
        double r731119 = r731117 / r731118;
        return r731119;
}

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