Average Error: 39.7 → 0.3
Time: 12.0s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00010271566703864994:\\ \;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\ \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.7
Target38.9
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.00010271566703864994

    1. Initial program 0.1

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

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

    if -0.00010271566703864994 < x

    1. Initial program 60.2

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

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

      \[\leadsto \frac{1}{2} \cdot x + \color{blue}{\log \left(e^{\frac{1}{6} \cdot {x}^{2} + 1}\right)}\]
    5. 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)\]
    6. 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)}\]
    7. 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.00010271566703864994:\\ \;\;\;\;\frac{\log \left(e^{e^{x} - 1}\right)}{x}\\ \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: 12.0s)Debug logProfile

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