Average Error: 40.2 → 0.3
Time: 51.2s
Precision: 64
Internal Precision: 1344
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{e^{x} - 1}{x} \le 0.0:\\ \;\;\;\;\sqrt[3]{\left(\left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right) \cdot \left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right)\right) \cdot \left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right)}\\ \mathbf{elif}\;\frac{e^{x} - 1}{x} \le 0.9877278429083478:\\ \;\;\;\;\frac{-1 + e^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x} - 1}{x} \le 1.753990269224867:\\ \;\;\;\;\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 + e^{x}}{x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original40.2
Target39.4
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 3 regimes
  2. if (/ (- (exp x) 1) x) < 0.0

    1. Initial program 62.0

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

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

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

    if 0.0 < (/ (- (exp x) 1) x) < 0.9877278429083478 or 1.753990269224867 < (/ (- (exp x) 1) x)

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{-1 \cdot \frac{1 - e^{x}}{x}}\]
    3. Simplified0.3

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

    if 0.9877278429083478 < (/ (- (exp x) 1) x) < 1.753990269224867

    1. Initial program 23.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{e^{x} - 1}{x} \le 0.0:\\ \;\;\;\;\sqrt[3]{\left(\left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right) \cdot \left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right)\right) \cdot \left(\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\right)}\\ \mathbf{elif}\;\frac{e^{x} - 1}{x} \le 0.9877278429083478:\\ \;\;\;\;\frac{-1 + e^{x}}{x}\\ \mathbf{elif}\;\frac{e^{x} - 1}{x} \le 1.753990269224867:\\ \;\;\;\;\left({x}^{2} \cdot \frac{1}{6} + 1\right) + \frac{1}{2} \cdot x\\ \mathbf{else}:\\ \;\;\;\;\frac{-1 + e^{x}}{x}\\ \end{array}\]

Runtime

Time bar (total: 51.2s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes20.70.30.020.798.9%
herbie shell --seed 2018274 
(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))