Average Error: 39.5 → 0.3
Time: 49.7s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -0.00018190747476085292:\\ \;\;\;\;\frac{e^{x}}{x} - \frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)} \cdot \left(\frac{1}{36} \cdot {x}^{2} + \left(1 + \frac{1}{6} \cdot x\right)\right)\right) \cdot \left(\frac{1}{36} \cdot {x}^{2} + \left(1 + \frac{1}{6} \cdot x\right)\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original39.5
Target38.7
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.00018190747476085292

    1. Initial program 0.0

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

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

    if -0.00018190747476085292 < x

    1. Initial program 60.0

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

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)} \cdot \sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)}\right) \cdot \sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)}}\]
    5. Taylor expanded around 0 0.5

      \[\leadsto \left(\sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)} \cdot \sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)}\right) \cdot \color{blue}{\left(\frac{1}{36} \cdot {x}^{2} + \left(1 + \frac{1}{6} \cdot x\right)\right)}\]
    6. Taylor expanded around 0 0.5

      \[\leadsto \left(\sqrt[3]{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)} \cdot \color{blue}{\left(\frac{1}{36} \cdot {x}^{2} + \left(1 + \frac{1}{6} \cdot x\right)\right)}\right) \cdot \left(\frac{1}{36} \cdot {x}^{2} + \left(1 + \frac{1}{6} \cdot x\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 49.7s)Debug logProfile

herbie shell --seed '#(1063154770 1824007522 645063331 41291047 494775821 1237684644)' 
(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))