Average Error: 32.9 → 0.1
Time: 53.7s
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -2.8896079110395453 \cdot 10^{-06}:\\
\;\;\;\;\sqrt[3]{{\left(e^{x \cdot a} - 1\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{2} + \frac{1}{6} \cdot \left(x \cdot a\right)\right) \cdot \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) + x \cdot a\\
\end{array}\]
Target
| Original | 32.9 |
|---|
| Target | 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) < -2.8896079110395453e-06
Initial program 0.2
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-cbrt-cube0.2
\[\leadsto \color{blue}{\sqrt[3]{\left(\left(e^{a \cdot x} - 1\right) \cdot \left(e^{a \cdot x} - 1\right)\right) \cdot \left(e^{a \cdot x} - 1\right)}}\]
Applied simplify0.2
\[\leadsto \sqrt[3]{\color{blue}{{\left(e^{x \cdot a} - 1\right)}^{3}}}\]
if -2.8896079110395453e-06 < (* a x)
Initial program 47.1
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-cbrt-cube47.1
\[\leadsto \color{blue}{\sqrt[3]{\left(\left(e^{a \cdot x} - 1\right) \cdot \left(e^{a \cdot x} - 1\right)\right) \cdot \left(e^{a \cdot x} - 1\right)}}\]
Applied simplify47.1
\[\leadsto \sqrt[3]{\color{blue}{{\left(e^{x \cdot a} - 1\right)}^{3}}}\]
Taylor expanded around 0 49.5
\[\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 simplify0.1
\[\leadsto \color{blue}{\left(\frac{1}{2} + \frac{1}{6} \cdot \left(x \cdot a\right)\right) \cdot \left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) + x \cdot a}\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1063027428 1192549564 1443466578 604016274 3637110559 1698629644)'
(FPCore (a x)
:name "expax (section 3.5)"
:herbie-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))