Average Error: 40.0 → 0.2
Time: 39.8s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - 1}{x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -0.022260873555785567:\\
\;\;\;\;\frac{\frac{e^{x + x} - 1}{e^{x} + 1}}{x}\\
\mathbf{else}:\\
\;\;\;\;\frac{{\left(e^{x}\right)}^{\left(x \cdot \frac{1}{24} + \frac{1}{2}\right)}}{{\left(e^{\frac{1}{2880}}\right)}^{\left({x}^{4}\right)}}\\
\end{array}\]
Target
| Original | 40.0 |
|---|
| Target | 39.2 |
|---|
| Herbie | 0.2 |
|---|
\[\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 < -0.022260873555785567
Initial program 0.0
\[\frac{e^{x} - 1}{x}\]
- Using strategy
rm Applied flip--0.0
\[\leadsto \frac{\color{blue}{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{e^{x} + 1}}}{x}\]
Applied simplify0.0
\[\leadsto \frac{\frac{\color{blue}{e^{x + x} - 1}}{e^{x} + 1}}{x}\]
if -0.022260873555785567 < x
Initial program 60.0
\[\frac{e^{x} - 1}{x}\]
- Using strategy
rm Applied add-exp-log60.0
\[\leadsto \color{blue}{e^{\log \left(\frac{e^{x} - 1}{x}\right)}}\]
Taylor expanded around 0 0.3
\[\leadsto e^{\color{blue}{\left(\frac{1}{24} \cdot {x}^{2} + \frac{1}{2} \cdot x\right) - \frac{1}{2880} \cdot {x}^{4}}}\]
Applied simplify0.3
\[\leadsto \color{blue}{\frac{{\left(e^{x}\right)}^{\left(x \cdot \frac{1}{24} + \frac{1}{2}\right)}}{{\left(e^{\frac{1}{2880}}\right)}^{\left({x}^{4}\right)}}}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1063313015 2771194459 1594909340 1344785158 2223560818 546365448)'
(FPCore (x)
:name "Kahan's exp quotient"
:herbie-target
(if (and (< x 1) (> x -1)) (/ (- (exp x) 1) (log (exp x))) (/ (- (exp x) 1) x))
(/ (- (exp x) 1) x))