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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 (pow (+ (* (* x 1/6) x) (+ 1 (* 1/2 x))) 3)) < 1.0001133699073637

    1. Initial program 60.5

      \[\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)}\]

    if 1.0001133699073637 < (cbrt (pow (+ (* (* x 1/6) x) (+ 1 (* 1/2 x))) 3))

    1. Initial program 0.1

      \[\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 associate-/l/0.1

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

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

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

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

Runtime

Time bar (total: 1.1m)Debug logProfile

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