Average Error: 43.1 → 0.1
Time: 13.1s
Precision: 64
Internal precision: 128
\[\frac{e^{x} - 1}{x}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -5.458497096453193 \cdot 10^{-06}:\\
\;\;\;\;\frac{{\left(\sqrt[3]{e^{x} - 1}\right)}^3}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{6} \cdot {x}^2 + \left(\frac{1}{2} \cdot x + 1\right)\\
\end{array}\]
Target
| Original | 43.1 |
| Comparison | 42.5 |
| Herbie | 0.1 |
\[ \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
- Split input into 2 regimes.
-
if x < -5.458497096453193e-06
Initial program 0.1
\[\frac{e^{x} - 1}{x}\]
- Using strategy
rm
Applied add-cube-cbrt 0.1
\[\leadsto \frac{\color{blue}{{\left(\sqrt[3]{e^{x} - 1}\right)}^3}}{x}\]
if -5.458497096453193e-06 < x
Initial program 60.7
\[\frac{e^{x} - 1}{x}\]
Applied taylor 0.1
\[\leadsto \frac{1}{6} \cdot {x}^2 + \left(\frac{1}{2} \cdot x + 1\right)\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{\frac{1}{6} \cdot {x}^2 + \left(\frac{1}{2} \cdot x + 1\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(503785802 245722208 3349178824 2475156670 1346783351 3951709736)'
(FPCore (x)
:name "Kahan's exp quotient"
:target
(if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))
(/ (- (exp x) 1) x))