Average Error: 39.6 → 0.4
Time: 20.6s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;\frac{\left(\frac{1}{6} \cdot x + \frac{1}{2}\right) \cdot \left(x \cdot x\right) + x}{x} \le 1.0000000000056495:\\ \;\;\;\;\frac{\left(\frac{1}{6} \cdot x + \frac{1}{2}\right) \cdot \left(x \cdot x\right) + x}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}{x}\\ \end{array}\]

Error

Bits error versus x

Target

Original39.6
Target38.8
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 (/ (+ (* (+ (* 1/6 x) 1/2) (* x x)) x) x) < 1.0000000000056495

    1. Initial program 60.7

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

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

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

    if 1.0000000000056495 < (/ (+ (* (+ (* 1/6 x) 1/2) (* x x)) x) x)

    1. Initial program 0.5

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.5

      \[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}{x}\]
    4. Applied difference-of-sqr-10.5

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

Runtime

Time bar (total: 20.6s)Debug log

herbie shell --seed '#(1151762963 887253659 3096734101 777879090 2714024476 786371635)' 
(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))