Average Error: 29.4 → 0.4
Time: 56.4s
Precision: 64
Internal Precision: 1344
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;e^{a \cdot x} - 1 \le -6.045090245343179 \cdot 10^{-06}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(\left(x \cdot \frac{1}{6}\right) \cdot a + \frac{1}{2}\right) + a \cdot x\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 29.4 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.4 |
|---|
\[\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 (- (exp (* a x)) 1) < -6.045090245343179e-06
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 -6.045090245343179e-06 < (- (exp (* a x)) 1)
Initial program 44.4
\[e^{a \cdot x} - 1\]
Taylor expanded around 0 13.7
\[\leadsto \color{blue}{\frac{1}{2} \cdot \left({a}^{2} \cdot {x}^{2}\right) + \left(a \cdot x + \frac{1}{6} \cdot \left({a}^{3} \cdot {x}^{3}\right)\right)}\]
Applied simplify0.5
\[\leadsto \color{blue}{\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(\left(x \cdot \frac{1}{6}\right) \cdot a + \frac{1}{2}\right) + a \cdot x}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed 2018296
(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))