Average Error: 39.7 → 0.4
Time: 33.4s
Precision: 64
Internal Precision: 1408
\[\frac{e^{x} - 1}{x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \le -9.37597390527974 \cdot 10^{-08}:\\
\;\;\;\;\frac{\sqrt{e^{x}} + 1}{\frac{x}{\sqrt{e^{x}} - 1}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)\\
\end{array}\]
Target
| Original | 39.7 |
|---|
| Target | 38.8 |
|---|
| Herbie | 0.4 |
|---|
\[\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 < -9.37597390527974e-08
Initial program 0.2
\[\frac{e^{x} - 1}{x}\]
- Using strategy
rm Applied add-sqr-sqrt0.2
\[\leadsto \frac{\color{blue}{\sqrt{e^{x}} \cdot \sqrt{e^{x}}} - 1}{x}\]
Applied difference-of-sqr-10.2
\[\leadsto \frac{\color{blue}{\left(\sqrt{e^{x}} + 1\right) \cdot \left(\sqrt{e^{x}} - 1\right)}}{x}\]
Applied associate-/l*0.2
\[\leadsto \color{blue}{\frac{\sqrt{e^{x}} + 1}{\frac{x}{\sqrt{e^{x}} - 1}}}\]
if -9.37597390527974e-08 < x
Initial program 60.2
\[\frac{e^{x} - 1}{x}\]
Taylor expanded around 0 0.5
\[\leadsto \color{blue}{\frac{1}{6} \cdot {x}^{2} + \left(1 + \frac{1}{2} \cdot x\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1063027428 1192549564 1443466578 604016274 3637110559 1698629644)'
(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))