Average Error: 40.1 → 0.5
Time: 2.0m
Precision: 64
Internal Precision: 1344
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right) \le 36.52280345363933:\\ \;\;\;\;\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{{\left(e^{x} - 1\right)}^{3}}}{x}\\ \end{array}\]

Error

Bits error versus x

Target

Original40.1
Target39.2
Herbie0.5
\[\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 (+ (* 1/6 (pow x 2)) (+ 1 (* 1/2 x))) < 36.52280345363933

    1. Initial program 59.7

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

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

    if 36.52280345363933 < (+ (* 1/6 (pow x 2)) (+ 1 (* 1/2 x)))

    1. Initial program 0.0

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

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(e^{x} - 1\right) \cdot \left(e^{x} - 1\right)\right) \cdot \left(e^{x} - 1\right)}}}{x}\]
    4. Applied simplify0.2

      \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(e^{x} - 1\right)}^{3}}}}{x}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 2.0m)Debug logProfile

herbie shell --seed '#(1071215679 2002590028 935158157 1944352234 2656991306 2955288481)' 
(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))