Average Error: 32.4 → 0.1
Time: 21.7s
Precision: 64
Internal precision: 1408
\[e^{a \cdot x} - 1\]
⬇
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -9.689533085427536 \cdot 10^{-06}:\\
\;\;\;\;\sqrt[3]{{\left(e^{a \cdot x} - 1\right)}^3}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{2} + a \cdot \left(x \cdot \frac{1}{6}\right)\right) \cdot {\left(a \cdot x\right)}^2 + x \cdot a\\
\end{array}\]
Target
| Original | 32.4 |
| Comparison | 5.9 |
| 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) < -9.689533085427536e-06
Initial program 0.1
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-cbrt-cube 0.1
\[\leadsto \color{blue}{\sqrt[3]{{\left(e^{a \cdot x} - 1\right)}^3}}\]
if -9.689533085427536e-06 < (* a x)
Initial program 46.9
\[e^{a \cdot x} - 1\]
- Using strategy
rm
Applied add-cbrt-cube 46.9
\[\leadsto \color{blue}{\sqrt[3]{{\left(e^{a \cdot x} - 1\right)}^3}}\]
Applied taylor 49.9
\[\leadsto e^{\log a + \log x} + \left(\frac{1}{2} \cdot \left(e^{\log a + \log x} \cdot \left(x \cdot a\right)\right) + \frac{1}{6} \cdot \left(e^{\log a + \log x} \cdot \left({x}^2 \cdot {a}^2\right)\right)\right)\]
Taylor expanded around 0 49.9
\[\leadsto \color{blue}{e^{\log a + \log x} + \left(\frac{1}{2} \cdot \left(e^{\log a + \log x} \cdot \left(x \cdot a\right)\right) + \frac{1}{6} \cdot \left(e^{\log a + \log x} \cdot \left({x}^2 \cdot {a}^2\right)\right)\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\left(\left(x \cdot a\right) \cdot \frac{1}{6} + \frac{1}{2}\right) \cdot \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) + x \cdot a}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\left(\frac{1}{2} + a \cdot \left(x \cdot \frac{1}{6}\right)\right) \cdot {\left(a \cdot x\right)}^2} + x \cdot a\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie shell --seed '#(2277612311 2645429965 1090895633 2857793080 2144184008 3989768357)'
(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))