Average Error: 40.4 → 28.0
Time: 4.3s
Precision: binary64
\[\frac{e^{x} - 1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \leq -5.90810225076708 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{{\left(e^{2}\right)}^{x} + -1}{e^{x} + 1}}{x}\\ \mathbf{elif}\;x \leq -1.782095466920453 \cdot 10^{-103} \lor \neg \left(x \leq 1.7508536288384564 \cdot 10^{-103}\right):\\ \;\;\;\;\frac{{\left(\frac{e^{x}}{x}\right)}^{3} - 8}{4 + \frac{{\left(\sqrt[3]{\frac{e^{x}}{x}}\right)}^{6}}{x}}\\ \mathbf{else}:\\ \;\;\;\;\langle \left( \langle \left( \frac{e^{x}}{x} - 2 \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\ \end{array}\]
\frac{e^{x} - 1}{x}
\begin{array}{l}
\mathbf{if}\;x \leq -5.90810225076708 \cdot 10^{-09}:\\
\;\;\;\;\frac{\frac{{\left(e^{2}\right)}^{x} + -1}{e^{x} + 1}}{x}\\

\mathbf{elif}\;x \leq -1.782095466920453 \cdot 10^{-103} \lor \neg \left(x \leq 1.7508536288384564 \cdot 10^{-103}\right):\\
\;\;\;\;\frac{{\left(\frac{e^{x}}{x}\right)}^{3} - 8}{4 + \frac{{\left(\sqrt[3]{\frac{e^{x}}{x}}\right)}^{6}}{x}}\\

\mathbf{else}:\\
\;\;\;\;\langle \left( \langle \left( \frac{e^{x}}{x} - 2 \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\

\end{array}
(FPCore (x) :precision binary64 (/ (- (exp x) 1.0) x))
(FPCore (x)
 :precision binary64
 (if (<= x -5.90810225076708e-09)
   (/ (/ (+ (pow (exp 2.0) x) -1.0) (+ (exp x) 1.0)) x)
   (if (or (<= x -1.782095466920453e-103) (not (<= x 1.7508536288384564e-103)))
     (/
      (- (pow (/ (exp x) x) 3.0) 8.0)
      (+ 4.0 (/ (pow (cbrt (/ (exp x) x)) 6.0) x)))
     (cast
      (!
       :precision
       posit16
       (cast (! :precision binary64 (- (/ (exp x) x) 2.0))))))))

Error

Bits error versus x

Target

Original40.4
Target40.8
Herbie28.0
\[\begin{array}{l} \mathbf{if}\;x < 1 \land x > -1:\\ \;\;\;\;\frac{e^{x} - 1}{\log \left(e^{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{x} - 1}{x}\\ \end{array}\]

Derivation

  1. Split input into 3 regimes
  2. if x < -5.9081022507670803e-9

    1. Initial program 0.3

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

      \[\leadsto \frac{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}{x}\]
    4. Simplified0.3

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

    if -5.9081022507670803e-9 < x < -1.78209546692045299e-103 or 1.7508536288384564e-103 < x

    1. Initial program 56.9

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied div-sub_binary6455.5

      \[\leadsto \color{blue}{\frac{e^{x}}{x} - \frac{1}{x}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary6457.1

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{x}{\sqrt[3]{e^{x}}}}} - \frac{1}{x}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt_binary6456.5

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{x}{\sqrt[3]{e^{x}}}}} \cdot \sqrt[3]{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{x}{\sqrt[3]{e^{x}}}}}\right) \cdot \sqrt[3]{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{x}{\sqrt[3]{e^{x}}}}}} - \frac{1}{x}\]
    9. Simplified56.1

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

      \[\leadsto \left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \color{blue}{\sqrt[3]{\frac{e^{x}}{x}}} - \frac{1}{x}\]
    11. Using strategy rm
    12. Applied flip3--_binary6456.6

      \[\leadsto \color{blue}{\frac{{\left(\left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \sqrt[3]{\frac{e^{x}}{x}}\right)}^{3} - {\left(\frac{1}{x}\right)}^{3}}{\left(\left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \left(\left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) + \left(\frac{1}{x} \cdot \frac{1}{x} + \left(\left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \frac{1}{x}\right)}}\]
    13. Simplified60.4

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

      \[\leadsto \frac{{\left(\frac{e^{x}}{x}\right)}^{3} - 8}{\color{blue}{4 + \frac{{\left(\sqrt[3]{\frac{e^{x}}{x}}\right)}^{6}}{x}}}\]

    if -1.78209546692045299e-103 < x < 1.7508536288384564e-103

    1. Initial program 62.0

      \[\frac{e^{x} - 1}{x}\]
    2. Using strategy rm
    3. Applied div-sub_binary6462.0

      \[\leadsto \color{blue}{\frac{e^{x}}{x} - \frac{1}{x}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary6462.0

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}\right) \cdot \sqrt[3]{e^{x}}}}{x} - \frac{1}{x}\]
    6. Applied associate-/l*_binary6462.0

      \[\leadsto \color{blue}{\frac{\sqrt[3]{e^{x}} \cdot \sqrt[3]{e^{x}}}{\frac{x}{\sqrt[3]{e^{x}}}}} - \frac{1}{x}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt_binary6462.2

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

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

      \[\leadsto \left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \color{blue}{\sqrt[3]{\frac{e^{x}}{x}}} - \frac{1}{x}\]
    11. Using strategy rm
    12. Applied insert-posit1660.3

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\left(\sqrt[3]{\frac{e^{x}}{x}} \cdot \sqrt[3]{\frac{e^{x}}{x}}\right) \cdot \sqrt[3]{\frac{e^{x}}{x}} - \frac{1}{x}} \right)_{binary64}} \rangle_{posit16}} \right)_{posit16}} \rangle_{binary64}}\]
    13. Simplified59.9

      \[\leadsto \langle \left( \langle \left( \color{blue}{\frac{e^{x}}{x}} - 2 \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification28.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.90810225076708 \cdot 10^{-09}:\\ \;\;\;\;\frac{\frac{{\left(e^{2}\right)}^{x} + -1}{e^{x} + 1}}{x}\\ \mathbf{elif}\;x \leq -1.782095466920453 \cdot 10^{-103} \lor \neg \left(x \leq 1.7508536288384564 \cdot 10^{-103}\right):\\ \;\;\;\;\frac{{\left(\frac{e^{x}}{x}\right)}^{3} - 8}{4 + \frac{{\left(\sqrt[3]{\frac{e^{x}}{x}}\right)}^{6}}{x}}\\ \mathbf{else}:\\ \;\;\;\;\langle \left( \langle \left( \frac{e^{x}}{x} - 2 \right)_{binary64} \rangle_{posit16} \right)_{posit16} \rangle_{binary64}\\ \end{array}\]

Reproduce

herbie shell --seed 2020299 
(FPCore (x)
  :name "Kahan's exp quotient"
  :precision binary64

  :herbie-target
  (if (and (< x 1.0) (> x -1.0)) (/ (- (exp x) 1.0) (log (exp x))) (/ (- (exp x) 1.0) x))

  (/ (- (exp x) 1.0) x))