Average Error: 32.7 → 1.1
Time: 56.8s
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;a \cdot x \le -2.9086861004764906 \cdot 10^{-20}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\mathbf{else}:\\
\;\;\;\;e^{\log \left(\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(x \cdot \left(\frac{1}{6} \cdot a\right) + \frac{1}{2}\right)\right)} + a \cdot x\\
\end{array}\]
Target
| Original | 32.7 |
|---|
| Target | 6.0 |
|---|
| Herbie | 1.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.9086861004764906e-20
Initial program 1.8
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-log-exp1.8
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
if -2.9086861004764906e-20 < (* a x)
Initial program 47.4
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-log-exp47.4
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
Taylor expanded around 0 47.9
\[\leadsto \log \left(e^{\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)}}\right)\]
Applied simplify14.3
\[\leadsto \color{blue}{\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right) + a \cdot x}\]
- Using strategy
rm Applied add-exp-log14.6
\[\leadsto \color{blue}{e^{\log \left(\left(a \cdot a\right) \cdot \left({x}^{3} \cdot \left(a \cdot \frac{1}{6}\right) + x \cdot \left(\frac{1}{2} \cdot x\right)\right)\right)}} + a \cdot x\]
Applied simplify0.8
\[\leadsto e^{\color{blue}{\log \left(\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(x \cdot \left(\frac{1}{6} \cdot a\right) + \frac{1}{2}\right)\right)}} + a \cdot x\]
- Recombined 2 regimes into one program.
- Removed slow
pow expressions.
Runtime
herbie shell --seed '#(1062930989 876886121 3990119081 3032829768 3060892583 1929069376)'
(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))