Average Error: 39.7 → 0.4
Time: 7.7s
Precision: 64
Internal Precision: 128
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.4541096338942166 \cdot 10^{-05}:\\ \;\;\;\;\frac{e^{\left(\left(\left(x + x\right) + \left(x + x\right)\right) + \left(\left(x + x\right) + \left(x + x\right)\right)\right) + x} + -1}{\left(x \cdot \left(e^{x} \cdot e^{x} + \left(1 + e^{x}\right)\right)\right) \cdot \left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(e^{\left(x + x\right) + x} + 1\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;1 + \left(x \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot x\\ \end{array}\]

Error

Bits error versus x

Target

Original39.7
Target38.9
Herbie0.4
\[\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.4541096338942166e-05

    1. Initial program 0.1

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

      \[\leadsto \frac{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}}{x}\]
    4. Applied associate-/l/0.1

      \[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{x \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)}}\]
    5. Simplified0.1

      \[\leadsto \frac{\color{blue}{e^{\left(x + x\right) + x} - 1}}{x \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)}\]
    6. Using strategy rm
    7. Applied flip3--0.1

      \[\leadsto \frac{\color{blue}{\frac{{\left(e^{\left(x + x\right) + x}\right)}^{3} - {1}^{3}}{e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 \cdot 1 + e^{\left(x + x\right) + x} \cdot 1\right)}}}{x \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)}\]
    8. Applied associate-/l/0.1

      \[\leadsto \color{blue}{\frac{{\left(e^{\left(x + x\right) + x}\right)}^{3} - {1}^{3}}{\left(x \cdot \left(e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)\right)\right) \cdot \left(e^{\left(x + x\right) + x} \cdot e^{\left(x + x\right) + x} + \left(1 \cdot 1 + e^{\left(x + x\right) + x} \cdot 1\right)\right)}}\]
    9. Simplified0.0

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

    if -5.4541096338942166e-05 < x

    1. Initial program 60.0

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

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

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

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

Reproduce

herbie shell --seed 2019051 
(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))