Average Error: 0.0 → 0.0
Time: 13.7s
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{1}{e^{x}} \cdot \cos y\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{1}{e^{x}} \cdot \cos y\right)}{2}
double f(double x, double y) {
        double r684697 = x;
        double r684698 = exp(r684697);
        double r684699 = -r684697;
        double r684700 = exp(r684699);
        double r684701 = r684698 + r684700;
        double r684702 = 2.0;
        double r684703 = r684701 / r684702;
        double r684704 = y;
        double r684705 = cos(r684704);
        double r684706 = r684703 * r684705;
        double r684707 = r684698 - r684700;
        double r684708 = r684707 / r684702;
        double r684709 = sin(r684704);
        double r684710 = r684708 * r684709;
        double r684711 = /* ERROR: no complex support in C */;
        double r684712 = /* ERROR: no complex support in C */;
        return r684712;
}

double f(double x, double y) {
        double r684713 = y;
        double r684714 = cos(r684713);
        double r684715 = x;
        double r684716 = exp(r684715);
        double r684717 = 1.0;
        double r684718 = r684717 / r684716;
        double r684719 = r684718 * r684714;
        double r684720 = fma(r684714, r684716, r684719);
        double r684721 = 2.0;
        double r684722 = r684720 / r684721;
        return r684722;
}

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. Using strategy rm
  4. Applied div-inv0.0

    \[\leadsto \frac{\mathsf{fma}\left(\cos y, e^{x}, \color{blue}{\cos y \cdot \frac{1}{e^{x}}}\right)}{2}\]
  5. Final simplification0.0

    \[\leadsto \frac{\mathsf{fma}\left(\cos y, e^{x}, \frac{1}{e^{x}} \cdot \cos y\right)}{2}\]

Reproduce

herbie shell --seed 2019141 +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)))))