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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original39.9
Target39.1
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.00016854183296784124

    1. Initial program 0.0

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

      \[\leadsto \frac{-1 + e^{x}}{x}\]
    3. Using strategy rm
    4. Applied clear-num0.0

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

    if -0.00016854183296784124 < x

    1. Initial program 60.1

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

      \[\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)}\]
    4. Using strategy rm
    5. Applied add-log-exp0.4

      \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\log \left(e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)}\]
    6. Applied add-log-exp0.4

      \[\leadsto \color{blue}{\log \left(e^{\frac{1}{2} \cdot x}\right)} + \log \left(e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)\]
    7. Applied sum-log0.4

      \[\leadsto \color{blue}{\log \left(e^{\frac{1}{2} \cdot x} \cdot e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)}\]
    8. Simplified0.4

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

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

Runtime

Time bar (total: 9.4s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes21.30.30.021.298.9%
herbie shell --seed 2018354 
(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))