Average Error: 58.0 → 1.9
Time: 3.2s
Precision: binary64
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[x + \left(\frac{2}{15} \cdot {x}^{5} - \frac{1}{3} \cdot {x}^{3}\right)\]

Error

Bits error versus x

Derivation

  1. Initial program 58.0

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
  2. Taylor expanded around 0 1.9

    \[\leadsto \color{blue}{\left(x + \frac{2}{15} \cdot {x}^{5}\right) - \frac{1}{3} \cdot {x}^{3}}\]
  3. Using strategy rm
  4. Applied associate--l+1.9

    \[\leadsto \color{blue}{x + \left(\frac{2}{15} \cdot {x}^{5} - \frac{1}{3} \cdot {x}^{3}\right)}\]
  5. Final simplification1.9

    \[\leadsto x + \left(\frac{2}{15} \cdot {x}^{5} - \frac{1}{3} \cdot {x}^{3}\right)\]

Reproduce

herbie shell --seed 2020174 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (neg x))) (+ (exp x) (exp (neg x)))))