Average Error: 45.5 → 0.2
Time: 12.6s
Precision: 64
Internal precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -1.3260991409638585 \cdot 10^{-12}:\\
\;\;\;\;\frac{e^{x}}{{\left(e^{x}\right)}^3 - 1} \cdot \left({\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)\right)\\
\mathbf{if}\;x \le 7.988163388129748:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1 - {\left(e^{-x}\right)}^3}{\left(1 + {\left(e^{2}\right)}^{\left(-x\right)}\right) + e^{-x}}}\\
\end{array}\]
Target
| Original | 45.5 |
| Comparison | 30.1 |
| Herbie | 0.2 |
\[ \frac{1}{1 - e^{-x}} \]
Derivation
- Split input into 3 regimes.
-
if x < -1.3260991409638585e-12
Initial program 0.6
\[\frac{e^{x}}{e^{x} - 1}\]
- Using strategy
rm
Applied flip3-- 0.6
\[\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 associate-/r/ 0.6
\[\leadsto \color{blue}{\frac{e^{x}}{{\left(e^{x}\right)}^{3} - {1}^{3}} \cdot \left({\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)\right)}\]
Applied simplify 0.6
\[\leadsto \color{blue}{\frac{e^{x}}{{\left(e^{x}\right)}^3 - 1}} \cdot \left({\left(e^{x}\right)}^2 + \left({1}^2 + e^{x} \cdot 1\right)\right)\]
if -1.3260991409638585e-12 < x < 7.988163388129748
Initial program 61.0
\[\frac{e^{x}}{e^{x} - 1}\]
Applied taylor 0.0
\[\leadsto \frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)}\]
if 7.988163388129748 < x
Initial program 61.7
\[\frac{e^{x}}{e^{x} - 1}\]
- Using strategy
rm
Applied clear-num 61.7
\[\leadsto \color{blue}{\frac{1}{\frac{e^{x} - 1}{e^{x}}}}\]
Applied simplify 0.0
\[\leadsto \frac{1}{\color{blue}{1 - e^{-x}}}\]
- Using strategy
rm
Applied flip3-- 0.0
\[\leadsto \frac{1}{\color{blue}{\frac{{1}^{3} - {\left(e^{-x}\right)}^{3}}{{1}^2 + \left({\left(e^{-x}\right)}^2 + 1 \cdot e^{-x}\right)}}}\]
Applied simplify 0.0
\[\leadsto \frac{1}{\frac{\color{blue}{1 - {\left(e^{-x}\right)}^3}}{{1}^2 + \left({\left(e^{-x}\right)}^2 + 1 \cdot e^{-x}\right)}}\]
Applied simplify 0.0
\[\leadsto \frac{1}{\frac{1 - {\left(e^{-x}\right)}^3}{\color{blue}{\left(1 + {\left(e^{2}\right)}^{\left(-x\right)}\right) + e^{-x}}}}\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (x)
:name "expq2 (section 3.11)"
:target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))