Average Error: 40.1 → 0.3
Time: 11.6s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00011362446394606948:\\ \;\;\;\;\frac{\log \left(e^{-1 + e^{x}}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.1
Target39.3
Herbie0.3
\[\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 < -0.00011362446394606948

    1. Initial program 0.1

      \[\frac{e^{x} - 1}{x}\]
    2. Initial simplification0.1

      \[\leadsto \frac{-1 + e^{x}}{x}\]
    3. Using strategy rm
    4. Applied add-log-exp0.1

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

    if -0.00011362446394606948 < x

    1. Initial program 60.2

      \[\frac{e^{x} - 1}{x}\]
    2. Initial simplification60.2

      \[\leadsto \frac{-1 + e^{x}}{x}\]
    3. Taylor expanded around 0 0.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -0.00011362446394606948:\\ \;\;\;\;\frac{\log \left(e^{-1 + e^{x}}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot x + \left(\frac{1}{6} \cdot {x}^{2} + 1\right)\\ \end{array}\]

Runtime

Time bar (total: 11.6s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes20.80.30.220.699.3%
herbie shell --seed 2018263 
(FPCore (x)
  :name "Kahan's exp quotient"

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

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