Average Error: 33.0 → 0.1
Time: 1.1m
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -5.290658512887221 \cdot 10^{-07}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot a + \left(x \cdot a\right) \cdot \left(\frac{1}{2} \cdot \left(x \cdot a\right)\right)\\
\end{array}\]
Target
| Original | 33.0 |
|---|
| Target | 7.6 |
|---|
| Herbie | 0.1 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\left|a \cdot x\right| \lt \frac{1}{10}:\\
\;\;\;\;\left(a \cdot x\right) \cdot \left(1 + \left(\frac{a \cdot x}{2} + \frac{{\left(a \cdot x\right)}^{2}}{6}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{a \cdot x} - 1\\
\end{array}\]
Derivation
- Split input into 2 regimes
if (* a x) < -5.290658512887221e-07
Initial program 0.1
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-log-exp0.1
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
if -5.290658512887221e-07 < (* a x)
Initial program 47.1
\[e^{a \cdot x} - 1\]
Taylor expanded around 0 21.1
\[\leadsto \color{blue}{\frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right) + \left(\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + a \cdot x\right)}\]
Taylor expanded around inf 11.8
\[\leadsto \frac{1}{6} \cdot \color{blue}{0} + \left(\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + a \cdot x\right)\]
Applied simplify0.1
\[\leadsto \color{blue}{x \cdot a + \left(x \cdot a\right) \cdot \left(\frac{1}{2} \cdot \left(x \cdot a\right)\right)}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1062900086 561157142 2241869825 1166610429 2484609072 2159574644)'
(FPCore (a x)
:name "expax (section 3.5)"
:herbie-target
(if (< (fabs (* a x)) 1/10) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (pow (* a x) 2) 6)))) (- (exp (* a x)) 1))
(- (exp (* a x)) 1))