Average Error: 42.8 → 2.9
Time: 9.0s
Precision: 64
Internal precision: 1408
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.3260991409638585 \cdot 10^{-12}:\\ \;\;\;\;\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{\left({\left(e^{x}\right)}^2 + \left(e^{x} + 1\right)\right) \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^2 \cdot \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) + x}{x}\\ \end{array}\]

Error

Bits error versus x

Target

Original42.8
Comparison42.2
Herbie2.9
\[ \begin{array}{l} \mathbf{if}\;x \lt 1 \land x \gt -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array} \]

Derivation

  1. Split input into 2 regimes.
  2. if x < -1.3260991409638585e-12

    1. Initial program 0.6

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

      \[\leadsto \frac{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{{\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)}}}{x}\]
    4. Applied associate-/l/ 0.6

      \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{x \cdot \left({\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)\right)}}\]
    5. Applied simplify 0.6

      \[\leadsto \frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{\color{blue}{\left(e^{x + x} + \left(e^{x} + 1\right)\right) \cdot x}}\]
    6. Applied simplify 0.6

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

    if -1.3260991409638585e-12 < x

    1. Initial program 60.9

      \[\frac{e^{x} - 1}{x}\]
    2. Applied taylor 4.0

      \[\leadsto \frac{\frac{1}{2} \cdot {x}^2 + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}{x}\]
    3. Taylor expanded around 0 4.0

      \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot {x}^2 + \left(\frac{1}{6} \cdot {x}^{3} + x\right)}}{x}\]
    4. Applied simplify 4.0

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

Runtime

Time bar (total: 9.0s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (x)
  :name "Kahan's exp quotient"

  :target
  (if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))

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