Average Error: 31.7 → 0.1
Time: 9.0s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -3.2061054256324616 \cdot 10^{-05}:\\
\;\;\;\;{\left(\sqrt[3]{\sqrt{e^{a \cdot x}} + 1} \cdot \sqrt[3]{\sqrt{e^{a \cdot x}} - 1}\right)}^3\\
\mathbf{else}:\\
\;\;\;\;x \cdot a + \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \left(\frac{1}{2} + \left(a \cdot \frac{1}{6}\right) \cdot x\right)\\
\end{array}\]
Target
| Original | 31.7 |
| Comparison | 6.0 |
| 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) < -3.2061054256324616e-05
Initial program 0.1
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-cube-cbrt 0.1
\[\leadsto \color{blue}{{\left(\sqrt[3]{e^{a \cdot x} - 1}\right)}^3}\]
- Using strategy
rm
Applied add-sqr-sqrt 0.1
\[\leadsto {\left(\sqrt[3]{\color{blue}{{\left(\sqrt{e^{a \cdot x}}\right)}^2} - 1}\right)}^3\]
Applied difference-of-sqr-1 0.1
\[\leadsto {\left(\sqrt[3]{\color{blue}{\left(\sqrt{e^{a \cdot x}} + 1\right) \cdot \left(\sqrt{e^{a \cdot x}} - 1\right)}}\right)}^3\]
Applied cbrt-prod 0.1
\[\leadsto {\color{blue}{\left(\sqrt[3]{\sqrt{e^{a \cdot x}} + 1} \cdot \sqrt[3]{\sqrt{e^{a \cdot x}} - 1}\right)}}^3\]
if -3.2061054256324616e-05 < (* a x)
Initial program 47.0
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-cube-cbrt 47.0
\[\leadsto \color{blue}{{\left(\sqrt[3]{e^{a \cdot x} - 1}\right)}^3}\]
Applied taylor 49.3
\[\leadsto \frac{1}{6} \cdot \left(e^{\log a + \log x} \cdot \left({a}^2 \cdot {x}^2\right)\right) + \left(e^{\log a + \log x} + \frac{1}{2} \cdot \left(e^{\log a + \log x} \cdot \left(a \cdot x\right)\right)\right)\]
Taylor expanded around 0 49.3
\[\leadsto \color{blue}{\frac{1}{6} \cdot \left(e^{\log a + \log x} \cdot \left({a}^2 \cdot {x}^2\right)\right) + \left(e^{\log a + \log x} + \frac{1}{2} \cdot \left(e^{\log a + \log x} \cdot \left(a \cdot x\right)\right)\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{x \cdot a + \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \left(\frac{1}{2} + \left(a \cdot \frac{1}{6}\right) \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 '#(1067488128 1186562765 67428877 2948030040 4169093828 3206893112)'
(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))