Average Error: 39.6 → 0.2
Time: 1.6m
Precision: 64
Internal Precision: 1408
\[\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 1.0000748758862645:\\ \;\;\;\;\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{3 \cdot x} - 1}{\left(\sqrt[3]{e^{x} \cdot e^{x} + \left(e^{x} + 1\right)} \cdot \sqrt[3]{e^{x} \cdot e^{x} + \left(e^{x} + 1\right)}\right) \cdot \left(x \cdot \sqrt[3]{\left(e^{x} + 1\right) + e^{x + x}}\right)}\\ \end{array}\]

Error

Bits error versus x

Target

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

    1. Initial program 60.4

      \[\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.0000748758862645 < (+ (* 1/6 (pow x 2)) (+ 1 (* 1/2 x)))

    1. Initial program 0.1

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

      \[\leadsto \frac{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{e^{x} \cdot e^{x} + \left(1 \cdot 1 + e^{x} \cdot 1\right)}}}{x}\]
    4. Applied associate-/l/0.2

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

      \[\leadsto \frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{\color{blue}{\left(e^{x} \cdot e^{x} + \left(e^{x} + 1\right)\right) \cdot x}}\]
    6. Taylor expanded around inf 0.2

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

      \[\leadsto \frac{e^{3 \cdot x} - 1}{\color{blue}{\left(\left(\sqrt[3]{e^{x} \cdot e^{x} + \left(e^{x} + 1\right)} \cdot \sqrt[3]{e^{x} \cdot e^{x} + \left(e^{x} + 1\right)}\right) \cdot \sqrt[3]{e^{x} \cdot e^{x} + \left(e^{x} + 1\right)}\right)} \cdot x}\]
    9. Applied associate-*l*0.2

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

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

Runtime

Time bar (total: 1.6m)Debug logProfile

herbie shell --seed '#(1070833653 108281690 3330367898 3632331308 3494323072 43156186)' 
(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))