Average Error: 38.0 → 8.7
Time: 22.4s
Precision: 64
Ground Truth: 128
\[e^{a \cdot x} - 1\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -1.1501639825495647 \cdot 10^{-13}:\\
\;\;\;\;e^{a \cdot x} - 1\\
\mathbf{else}:\\
\;\;\;\;\frac{2 \cdot \left(a \cdot x + {\left(a \cdot x\right)}^2\right)}{1 + e^{a \cdot x}}\\
\end{array}\]
Target
| Original | 38.0 |
| Comparison | 15.9 |
| Herbie | 8.7 |
\[ \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) < -1.1501639825495647e-13
Initial program 0.8
\[e^{a \cdot x} - 1\]
if -1.1501639825495647e-13 < (* a x)
Initial program 51.5
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied flip-- 51.5
\[\leadsto \color{blue}{\frac{{\left(e^{a \cdot x}\right)}^2 - {1}^2}{e^{a \cdot x} + 1}}\]
Applied taylor 47.5
\[\leadsto \frac{\left(2 \cdot \left(x \cdot a\right) + \left(1 + 2 \cdot \left({x}^2 \cdot {a}^2\right)\right)\right) - {1}^2}{e^{a \cdot x} + 1}\]
Taylor expanded around 0 47.5
\[\leadsto \frac{\color{blue}{\left(2 \cdot \left(x \cdot a\right) + \left(1 + 2 \cdot \left({x}^2 \cdot {a}^2\right)\right)\right)} - {1}^2}{e^{a \cdot x} + 1}\]
Applied simplify 11.5
\[\leadsto \color{blue}{\frac{2 \cdot \left(a \cdot x + {\left(a \cdot x\right)}^2\right)}{1 + e^{a \cdot x}}}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(1964145002 3596466598 2249905545 2281660312 2216507096 1439778181)'
(FPCore (a x)
:name "NMSE section 3.5"
:target
(if (< (fabs (* a x)) 1/10) (* (* a x) (+ 1 (+ (/ (* a x) 2) (/ (sqr (* a x)) 6)))) (- (exp (* a x)) 1))
(- (exp (* a x)) 1))