Average Error: 0.0 → 0.0
Time: 21.3s
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 r1487865 = x;
        double r1487866 = exp(r1487865);
        double r1487867 = -r1487865;
        double r1487868 = exp(r1487867);
        double r1487869 = r1487866 + r1487868;
        double r1487870 = 2.0;
        double r1487871 = r1487869 / r1487870;
        double r1487872 = y;
        double r1487873 = cos(r1487872);
        double r1487874 = r1487871 * r1487873;
        double r1487875 = r1487866 - r1487868;
        double r1487876 = r1487875 / r1487870;
        double r1487877 = sin(r1487872);
        double r1487878 = r1487876 * r1487877;
        double r1487879 = /* ERROR: no complex support in C */;
        double r1487880 = /* ERROR: no complex support in C */;
        return r1487880;
}

double f(double x, double y) {
        double r1487881 = x;
        double r1487882 = exp(r1487881);
        double r1487883 = y;
        double r1487884 = cos(r1487883);
        double r1487885 = r1487884 / r1487882;
        double r1487886 = fma(r1487882, r1487884, r1487885);
        double r1487887 = 2.0;
        double r1487888 = r1487886 / r1487887;
        return r1487888;
}

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