Average Error: 45.6 → 0.1
Time: 6.0s
Precision: 64
Internal precision: 1408
\[\frac{e^{x}}{e^{x} - 1}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -4.010384934750878 \cdot 10^{-06}:\\
\;\;\;\;\frac{e^{x}}{\log \left(e^{e^{x} - 1}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\\
\end{array}\]
Target
| Original | 45.6 |
| Comparison | 45.5 |
| Herbie | 0.1 |
\[ \frac{1}{1 - e^{-x}} \]
Derivation
- Split input into 2 regimes.
-
if x < -4.010384934750878e-06
Initial program 0.1
\[\frac{e^{x}}{e^{x} - 1}\]
- Using strategy
rm
Applied add-log-exp 0.1
\[\leadsto \frac{e^{x}}{\color{blue}{\log \left(e^{e^{x} - 1}\right)}}\]
if -4.010384934750878e-06 < x
Initial program 60.7
\[\frac{e^{x}}{e^{x} - 1}\]
Applied taylor 0.1
\[\leadsto \frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot x\right)\]
Taylor expanded around 0 0.1
\[\leadsto \color{blue}{\frac{1}{2} + \left(\frac{1}{x} + \frac{1}{12} \cdot 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 '#(1066785882 2324371342 4059510649 1466361199 2701357084 1216585281)'
(FPCore (x)
:name "expq2 (section 3.11)"
:target
(/ 1 (- 1 (exp (- x))))
(/ (exp x) (- (exp x) 1)))