Average Error: 29.2 → 0.3
Time: 24.6s
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;e^{a \cdot x} - 1 \le -4.855291007064373 \cdot 10^{-05}:\\
\;\;\;\;\sqrt[3]{{\left(\log \left(e^{e^{x \cdot a} - 1}\right)\right)}^{3}}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \left(x \cdot a\right)\right) + x \cdot a\\
\end{array}\]
Target
| Original | 29.2 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.3 |
|---|
\[\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 (- (exp (* a x)) 1) < -4.855291007064373e-05
Initial program 0.0
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-cbrt-cube0.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 simplify0.1
\[\leadsto \sqrt[3]{\color{blue}{{\left(e^{x \cdot a} - 1\right)}^{3}}}\]
- Using strategy
rm Applied add-log-exp0.1
\[\leadsto \sqrt[3]{{\color{blue}{\left(\log \left(e^{e^{x \cdot a} - 1}\right)\right)}}^{3}}\]
if -4.855291007064373e-05 < (- (exp (* a x)) 1)
Initial program 44.5
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-cbrt-cube44.6
\[\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 simplify44.6
\[\leadsto \sqrt[3]{\color{blue}{{\left(e^{x \cdot a} - 1\right)}^{3}}}\]
Taylor expanded around 0 50.9
\[\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.4
\[\leadsto \color{blue}{\left(\left(x \cdot a\right) \cdot \left(x \cdot a\right)\right) \cdot \left(\frac{1}{2} + \frac{1}{6} \cdot \left(x \cdot a\right)\right) + x \cdot a}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed '#(1064300848 3212030778 2049303162 3567222883 2277747821 1384278011)'
(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))