Average Error: 58.1 → 1.0
Time: 16.0s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.007182526423069286:\\ \;\;\;\;\frac{e^{x}}{e^{x} + e^{-x}} - \frac{1}{1 + e^{x + x}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - \frac{1}{3} \cdot {x}^{3}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.007182526423069286

    1. Initial program 35.7

      \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
    2. Using strategy rm
    3. Applied div-sub35.7

      \[\leadsto \color{blue}{\frac{e^{x}}{e^{x} + e^{-x}} - \frac{e^{-x}}{e^{x} + e^{-x}}}\]
    4. Applied simplify0.6

      \[\leadsto \frac{e^{x}}{e^{x} + e^{-x}} - \color{blue}{\frac{1}{e^{x} \cdot e^{x} + 1}}\]
    5. Applied simplify0.6

      \[\leadsto \frac{e^{x}}{e^{x} + e^{-x}} - \frac{1}{\color{blue}{1 + e^{x + x}}}\]

    if -0.007182526423069286 < x

    1. Initial program 58.6

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

      \[\leadsto \color{blue}{\left(\frac{2}{15} \cdot {x}^{5} + x\right) - \frac{1}{3} \cdot {x}^{3}}\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 16.0s)Debug logProfile

herbie shell --seed '#(1063313015 2771194459 1594909340 1344785158 2223560818 546365448)' 
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))