Average Error: 39.9 → 0.2
Time: 1.1m
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\sqrt[3]{x + \left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)} \cdot \sqrt[3]{x + \left(x \cdot x\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot x\right)}\right) \cdot \sqrt[3]{\left(\frac{1}{2} + \frac{1}{6} \cdot x\right) \cdot \left(x \cdot x\right) + x}}{x} \le 1.0003521562566515:\\ \;\;\;\;\sqrt[3]{{\left(\left(x \cdot \frac{1}{6}\right) \cdot x + \left(1 + \frac{1}{2} \cdot x\right)\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{e^{x + x} - 1}{e^{x} + 1}}{x}\\ \end{array}\]

Error

Bits error versus x

Target

Original39.9
Target39.1
Herbie0.2
\[\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 (/ (* (* (cbrt (+ x (* (* x x) (+ 1/2 (* 1/6 x))))) (cbrt (+ x (* (* x x) (+ 1/2 (* 1/6 x)))))) (cbrt (+ (* (+ 1/2 (* 1/6 x)) (* x x)) x))) x) < 1.0003521562566515

    1. Initial program 60.3

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

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

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

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

    if 1.0003521562566515 < (/ (* (* (cbrt (+ x (* (* x x) (+ 1/2 (* 1/6 x))))) (cbrt (+ x (* (* x x) (+ 1/2 (* 1/6 x)))))) (cbrt (+ (* (+ 1/2 (* 1/6 x)) (* x x)) x))) x)

    1. Initial program 0.0

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

      \[\leadsto \frac{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}{x}\]
    4. Applied simplify0.0

      \[\leadsto \frac{\frac{\color{blue}{e^{x + x} - 1}}{e^{x} + 1}}{x}\]
  3. Recombined 2 regimes into one program.

Runtime

Time bar (total: 1.1m)Debug logProfile

herbie shell --seed '#(1070960995 739739648 2531964651 3069671617 351857262 3877178482)' 
(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))