Average Error: 39.9 → 0.1
Time: 30.2s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x}}{e^{x} - 1}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\left(\frac{1}{6} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}} \le -128923.5709521659:\\ \;\;\;\;\frac{1}{\left(\frac{1}{6} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}}\\ \mathbf{if}\;\frac{1}{\left(\frac{1}{6} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}} \le 2408671.1225494705:\\ \;\;\;\;\frac{1}{1 - e^{-x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original39.9
Target39.6
Herbie0.1
\[\frac{1}{1 - e^{-x}}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ 1 (- (+ (* 1/6 (pow x 3)) x) (* 1/2 (pow x 2)))) < -128923.5709521659

    1. Initial program 62.4

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

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

      \[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
    5. Taylor expanded around 0 0.0

      \[\leadsto \frac{1}{\color{blue}{\left(\frac{1}{6} \cdot {x}^{3} + x\right) - \frac{1}{2} \cdot {x}^{2}}}\]

    if -128923.5709521659 < (/ 1 (- (+ (* 1/6 (pow x 3)) x) (* 1/2 (pow x 2)))) < 2408671.1225494705

    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.2

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

    if 2408671.1225494705 < (/ 1 (- (+ (* 1/6 (pow x 3)) x) (* 1/2 (pow x 2))))

    1. Initial program 59.6

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

      \[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]
  3. Recombined 3 regimes into one program.

Runtime

Time bar (total: 30.2s)Debug logProfile

herbie shell --seed '#(1071501266 3581234924 1086666455 2685055582 1243441566 1802958749)' 
(FPCore (x)
  :name "expq2 (section 3.11)"

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

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