Average Error: 58.0 → 0.0
Time: 39.2s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.004881342619957679:\\ \;\;\;\;\left(\sqrt[3]{\tanh x} \cdot \sqrt[3]{\tanh x}\right) \cdot \sqrt[3]{\tanh x}\\ \mathbf{if}\;x \le 0.00010460684905055491:\\ \;\;\;\;\left(\frac{2}{15} \cdot {x}^{5} + x\right) - \frac{1}{3} \cdot {x}^{3}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\tanh x} \cdot \sqrt[3]{\tanh x}\right) \cdot \sqrt[3]{\tanh x}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if x < -0.004881342619957679 or 0.00010460684905055491 < x

    1. Initial program 32.2

      \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
    2. Using strategy rm
    3. Applied tanh-undef0.1

      \[\leadsto \color{blue}{\tanh x}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt0.5

      \[\leadsto \color{blue}{\left(\sqrt[3]{\tanh x} \cdot \sqrt[3]{\tanh x}\right) \cdot \sqrt[3]{\tanh x}}\]

    if -0.004881342619957679 < x < 0.00010460684905055491

    1. Initial program 59.0

      \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}\]
    2. Taylor expanded around 0 0.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.

Runtime

Time bar (total: 39.2s)Debug logProfile

herbie shell --seed '#(1070578969 3140398606 632207097 462683394 1189254563 964980650)' +o rules:numerics
(FPCore (x)
  :name "Hyperbolic tangent"
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))