Average Error: 40.0 → 0.2
Time: 37.3s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1 - e^{-\left(x + x\right)}}{1 + e^{-x}} \le 0.0016832831634131951:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \end{array}\]

Error

Bits error versus x

Target

Original40.0
Target39.6
Herbie0.2
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (- 1 (exp (- (+ x x)))) (+ 1 (exp (- x)))) < 0.0016832831634131951

    1. Initial program 60.4

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

      \[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]

    if 0.0016832831634131951 < (/ (- 1 (exp (- (+ x x)))) (+ 1 (exp (- x))))

    1. Initial program 1.2

      \[\frac{e^{x}}{e^{x} - 1}\]
    2. Using strategy rm
    3. Applied clear-num1.2

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

      \[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 37.3s)Debug logProfile

herbie shell --seed '#(1072840222 1305617769 1692503039 1353360431 4178980589 1488672652)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

  :herbie-target
  (/ 1 (- 1 (exp (- x))))

  (/ (exp x) (- (exp x) 1)))