Average Error: 0.0 → 0.0
Time: 19.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 r1484778 = x;
        double r1484779 = exp(r1484778);
        double r1484780 = -r1484778;
        double r1484781 = exp(r1484780);
        double r1484782 = r1484779 + r1484781;
        double r1484783 = 2.0;
        double r1484784 = r1484782 / r1484783;
        double r1484785 = y;
        double r1484786 = cos(r1484785);
        double r1484787 = r1484784 * r1484786;
        double r1484788 = r1484779 - r1484781;
        double r1484789 = r1484788 / r1484783;
        double r1484790 = sin(r1484785);
        double r1484791 = r1484789 * r1484790;
        double r1484792 = /* ERROR: no complex support in C */;
        double r1484793 = /* ERROR: no complex support in C */;
        return r1484793;
}

double f(double x, double y) {
        double r1484794 = x;
        double r1484795 = exp(r1484794);
        double r1484796 = y;
        double r1484797 = cos(r1484796);
        double r1484798 = r1484797 / r1484795;
        double r1484799 = fma(r1484795, r1484797, r1484798);
        double r1484800 = 2.0;
        double r1484801 = r1484799 / r1484800;
        return r1484801;
}

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