Average Error: 43.1 → 0.1
Time: 13.1s
Precision: 64
Internal precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.458497096453193 \cdot 10^{-06}:\\ \;\;\;\;\frac{{\left(\sqrt[3]{e^{x} - 1}\right)}^3}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{6} \cdot {x}^2 + \left(\frac{1}{2} \cdot x + 1\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original43.1
Comparison42.5
Herbie0.1
\[ \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 < -5.458497096453193e-06

    1. Initial program 0.1

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt 0.1

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

    if -5.458497096453193e-06 < x

    1. Initial program 60.7

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

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

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

Runtime

Time bar (total: 13.1s) Debug log

Please include this information when filing a bug report:

herbie --seed '#(503785802 245722208 3349178824 2475156670 1346783351 3951709736)'
(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))