Average Error: 32.0 → 9.8
Time: 30.1s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -1.6430626687800177 \cdot 10^{-13}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right) + a \cdot x\\
\end{array}\]
Target
| Original | 32.0 |
| Comparison | 5.6 |
| Herbie | 9.8 |
\[ \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.6430626687800177e-13
Initial program 0.7
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-log-exp 0.7
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
if -1.6430626687800177e-13 < (* a x)
Initial program 46.8
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-log-exp 46.8
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
Applied taylor 47.6
\[\leadsto \log \left(e^{\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)}\right)\]
Taylor expanded around 0 47.6
\[\leadsto \log \left(e^{\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)}}\right)\]
Applied simplify 14.1
\[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right) + a \cdot x}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1068028399 4028058041 2917032441 2563479541 765645300 1132738916)'
(FPCore (a x)
:name "expax (section 3.5)"
: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))