Average Error: 0.0 → 0.0
Time: 14.1s
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 r1511918 = x;
        double r1511919 = exp(r1511918);
        double r1511920 = -r1511918;
        double r1511921 = exp(r1511920);
        double r1511922 = r1511919 + r1511921;
        double r1511923 = 2.0;
        double r1511924 = r1511922 / r1511923;
        double r1511925 = y;
        double r1511926 = cos(r1511925);
        double r1511927 = r1511924 * r1511926;
        double r1511928 = r1511919 - r1511921;
        double r1511929 = r1511928 / r1511923;
        double r1511930 = sin(r1511925);
        double r1511931 = r1511929 * r1511930;
        double r1511932 = /* ERROR: no complex support in C */;
        double r1511933 = /* ERROR: no complex support in C */;
        return r1511933;
}

double f(double x, double y) {
        double r1511934 = x;
        double r1511935 = exp(r1511934);
        double r1511936 = y;
        double r1511937 = cos(r1511936);
        double r1511938 = r1511937 / r1511935;
        double r1511939 = fma(r1511935, r1511937, r1511938);
        double r1511940 = 2.0;
        double r1511941 = r1511939 / r1511940;
        return r1511941;
}

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