Average Error: 45.1 → 0.1
Time: 11.1s
Precision: 64
Internal precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -4.695602164921309 \cdot 10^{-06}:\\
\;\;\;\;\frac{e^{x}}{\frac{{\left(e^{x}\right)}^3 - 1}{\left(e^{x} + 1\right) + e^{x + x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{12} \cdot x + \left(\frac{1}{2} + \frac{1}{x}\right)\\
\end{array}\]
Target
| Original | 45.1 |
| Comparison | 45.1 |
| Herbie | 0.1 |
\[ \frac{1}{1 - e^{-x}} \]
Derivation
- Split input into 2 regimes.
-
if x < -4.695602164921309e-06
Initial program 0.1
\[\frac{e^{x}}{e^{x} - 1}\]
- Using strategy
rm
Applied flip3-- 0.1
\[\leadsto \frac{e^{x}}{\color{blue}{\frac{{\left(e^{x}\right)}^{3} - {1}^{3}}{{\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)}}}\]
Applied simplify 0.1
\[\leadsto \frac{e^{x}}{\frac{\color{blue}{{\left(e^{x}\right)}^3 - 1}}{{\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)}}\]
Applied simplify 0.1
\[\leadsto \frac{e^{x}}{\frac{{\left(e^{x}\right)}^3 - 1}{\color{blue}{\left(e^{x} + 1\right) + e^{x + x}}}}\]
if -4.695602164921309e-06 < x
Initial program 60.6
\[\frac{e^{x}}{e^{x} - 1}\]
Applied taylor 0.1
\[\leadsto \frac{1}{12} \cdot x + \left(\frac{1}{2} + \frac{1}{x}\right)\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{\frac{1}{12} \cdot x + \left(\frac{1}{2} + \frac{1}{x}\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(3283856077 3183919125 3399458751 396155847 3688194147 1862413033)'
(FPCore (x)
:name "expq2 (section 3.11)"
:target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))