Average Error: 32.3 → 12.1
Time: 11.4s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -4.283222210193013 \cdot 10^{-14}:\\
\;\;\;\;\frac{e^{a \cdot \left(x + x\right)} - {1}^2}{{\left(\sqrt{e^{a \cdot x} + 1}\right)}^2}\\
\mathbf{else}:\\
\;\;\;\;\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)\\
\end{array}\]
Target
| Original | 32.3 |
| Comparison | 5.6 |
| Herbie | 12.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) < -4.283222210193013e-14
Initial program 0.9
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied flip-- 0.9
\[\leadsto \color{blue}{\frac{{\left(e^{a \cdot x}\right)}^2 - {1}^2}{e^{a \cdot x} + 1}}\]
- Using strategy
rm
Applied add-exp-log 0.9
\[\leadsto \frac{\color{blue}{e^{\log \left({\left(e^{a \cdot x}\right)}^2\right)}} - {1}^2}{e^{a \cdot x} + 1}\]
Applied simplify 0.9
\[\leadsto \frac{e^{\color{blue}{a \cdot \left(x + x\right)}} - {1}^2}{e^{a \cdot x} + 1}\]
- Using strategy
rm
Applied add-sqr-sqrt 0.9
\[\leadsto \frac{e^{a \cdot \left(x + x\right)} - {1}^2}{\color{blue}{{\left(\sqrt{e^{a \cdot x} + 1}\right)}^2}}\]
if -4.283222210193013e-14 < (* a x)
Initial program 46.9
\[e^{a \cdot x} - 1\]
Applied taylor 17.3
\[\leadsto \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 0 17.3
\[\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)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(1066372953 114334025 411438303 1288252006 2962405338 2829794477)'
(FPCore (a x)
:name "expax (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))