Average Error: 0.0 → 0.0
Time: 12.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, \cos y \cdot \frac{1}{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, \cos y \cdot \frac{1}{e^{x}}\right)}{2}
double f(double x, double y) {
        double r1484422 = x;
        double r1484423 = exp(r1484422);
        double r1484424 = -r1484422;
        double r1484425 = exp(r1484424);
        double r1484426 = r1484423 + r1484425;
        double r1484427 = 2.0;
        double r1484428 = r1484426 / r1484427;
        double r1484429 = y;
        double r1484430 = cos(r1484429);
        double r1484431 = r1484428 * r1484430;
        double r1484432 = r1484423 - r1484425;
        double r1484433 = r1484432 / r1484427;
        double r1484434 = sin(r1484429);
        double r1484435 = r1484433 * r1484434;
        double r1484436 = /* ERROR: no complex support in C */;
        double r1484437 = /* ERROR: no complex support in C */;
        return r1484437;
}

double f(double x, double y) {
        double r1484438 = x;
        double r1484439 = exp(r1484438);
        double r1484440 = y;
        double r1484441 = cos(r1484440);
        double r1484442 = 1.0;
        double r1484443 = r1484442 / r1484439;
        double r1484444 = r1484441 * r1484443;
        double r1484445 = fma(r1484439, r1484441, r1484444);
        double r1484446 = 2.0;
        double r1484447 = r1484445 / r1484446;
        return r1484447;
}

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

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

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

Reproduce

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