Average Error: 43.4 → 0.7
Time: 39.6s
Precision: 64
\[\Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
\[\Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{1}{3}, \mathsf{fma}\left(\frac{1}{60}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), 2 \cdot x\right)\right) \cdot \sin y}{2} i\right))\]
\Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))
\Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{1}{3}, \mathsf{fma}\left(\frac{1}{60}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), 2 \cdot x\right)\right) \cdot \sin y}{2} i\right))
double f(double x, double y) {
        double r1288376 = x;
        double r1288377 = exp(r1288376);
        double r1288378 = -r1288376;
        double r1288379 = exp(r1288378);
        double r1288380 = r1288377 + r1288379;
        double r1288381 = 2.0;
        double r1288382 = r1288380 / r1288381;
        double r1288383 = y;
        double r1288384 = cos(r1288383);
        double r1288385 = r1288382 * r1288384;
        double r1288386 = r1288377 - r1288379;
        double r1288387 = r1288386 / r1288381;
        double r1288388 = sin(r1288383);
        double r1288389 = r1288387 * r1288388;
        double r1288390 = /* ERROR: no complex support in C */;
        double r1288391 = /* ERROR: no complex support in C */;
        return r1288391;
}

double f(double x, double y) {
        double r1288392 = x;
        double r1288393 = exp(r1288392);
        double r1288394 = -r1288392;
        double r1288395 = exp(r1288394);
        double r1288396 = r1288393 + r1288395;
        double r1288397 = 2.0;
        double r1288398 = r1288396 / r1288397;
        double r1288399 = y;
        double r1288400 = cos(r1288399);
        double r1288401 = r1288398 * r1288400;
        double r1288402 = r1288392 * r1288392;
        double r1288403 = r1288402 * r1288392;
        double r1288404 = 0.3333333333333333;
        double r1288405 = 0.016666666666666666;
        double r1288406 = r1288402 * r1288403;
        double r1288407 = r1288397 * r1288392;
        double r1288408 = fma(r1288405, r1288406, r1288407);
        double r1288409 = fma(r1288403, r1288404, r1288408);
        double r1288410 = sin(r1288399);
        double r1288411 = r1288409 * r1288410;
        double r1288412 = r1288411 / r1288397;
        double r1288413 = /* ERROR: no complex support in C */;
        double r1288414 = /* ERROR: no complex support in C */;
        return r1288414;
}

Error

Bits error versus x

Bits error versus y

Derivation

  1. Initial program 43.4

    \[\Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
  2. Taylor expanded around 0 0.7

    \[\leadsto \Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\color{blue}{2 \cdot x + \left(\frac{1}{3} \cdot {x}^{3} + \frac{1}{60} \cdot {x}^{5}\right)}}{2} \cdot \sin y i\right))\]
  3. Simplified0.7

    \[\leadsto \Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{60}, {x}^{5}, x \cdot \left(2 + \frac{1}{3} \cdot \left(x \cdot x\right)\right)\right)}}{2} \cdot \sin y i\right))\]
  4. Using strategy rm
  5. Applied associate-*l/0.7

    \[\leadsto \Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \color{blue}{\frac{\mathsf{fma}\left(\frac{1}{60}, {x}^{5}, x \cdot \left(2 + \frac{1}{3} \cdot \left(x \cdot x\right)\right)\right) \cdot \sin y}{2}} i\right))\]
  6. Simplified0.7

    \[\leadsto \Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\color{blue}{\sin y \cdot \mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{1}{3}, \mathsf{fma}\left(\frac{1}{60}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), 2 \cdot x\right)\right)}}{2} i\right))\]
  7. Final simplification0.7

    \[\leadsto \Im(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot x, \frac{1}{3}, \mathsf{fma}\left(\frac{1}{60}, \left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot x\right), 2 \cdot x\right)\right) \cdot \sin y}{2} i\right))\]

Reproduce

herbie shell --seed 2019146 +o rules:numerics
(FPCore (x y)
  :name "Euler formula imaginary part (p55)"
  (im (complex (* (/ (+ (exp x) (exp (- x))) 2) (cos y)) (* (/ (- (exp x) (exp (- x))) 2) (sin y)))))