Average Error: 0.0 → 0.3
Time: 5.8s
Precision: 64
\[\Re(\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
\[\Re(\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(0.5, \cos y \cdot e^{x}, 0.5 \cdot \left(\cos y \cdot e^{-x}\right)\right)\right)\right) + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]

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. Using strategy rm
  3. Applied expm1-log1p-u0.3

    \[\leadsto \Re(\left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{e^{x} + e^{-x}}{2} \cdot \cos y\right)\right)} + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
  4. Taylor expanded around inf 0.7

    \[\leadsto \Re(\left(\mathsf{expm1}\left(\color{blue}{\log \left(0.5 \cdot \left(\cos y \cdot e^{x}\right) + \left(0.5 \cdot \left(\cos y \cdot e^{-x}\right) + 1\right)\right)}\right) + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
  5. Simplified0.3

    \[\leadsto \Re(\left(\mathsf{expm1}\left(\color{blue}{\mathsf{log1p}\left(\mathsf{fma}\left(0.5, \cos y \cdot e^{x}, 0.5 \cdot \left(\cos y \cdot e^{-x}\right)\right)\right)}\right) + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]
  6. Final simplification0.3

    \[\leadsto \Re(\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{fma}\left(0.5, \cos y \cdot e^{x}, 0.5 \cdot \left(\cos y \cdot e^{-x}\right)\right)\right)\right) + \frac{e^{x} - e^{-x}}{2} \cdot \sin y i\right))\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (x y)
  :name "Euler formula real part (p55)"
  :precision binary64
  (re (complex (* (/ (+ (exp x) (exp (- x))) 2) (cos y)) (* (/ (- (exp x) (exp (- x))) 2) (sin y)))))