Average Error: 0.0 → 0.0
Time: 14.6s
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 r1799812 = x;
        double r1799813 = exp(r1799812);
        double r1799814 = -r1799812;
        double r1799815 = exp(r1799814);
        double r1799816 = r1799813 + r1799815;
        double r1799817 = 2.0;
        double r1799818 = r1799816 / r1799817;
        double r1799819 = y;
        double r1799820 = cos(r1799819);
        double r1799821 = r1799818 * r1799820;
        double r1799822 = r1799813 - r1799815;
        double r1799823 = r1799822 / r1799817;
        double r1799824 = sin(r1799819);
        double r1799825 = r1799823 * r1799824;
        double r1799826 = /* ERROR: no complex support in C */;
        double r1799827 = /* ERROR: no complex support in C */;
        return r1799827;
}

double f(double x, double y) {
        double r1799828 = x;
        double r1799829 = exp(r1799828);
        double r1799830 = y;
        double r1799831 = cos(r1799830);
        double r1799832 = r1799831 / r1799829;
        double r1799833 = fma(r1799829, r1799831, r1799832);
        double r1799834 = 2.0;
        double r1799835 = r1799833 / r1799834;
        return r1799835;
}

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