Average Error: 29.4 → 0.6
Time: 37.9s
Precision: 64
Internal Precision: 1408
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;\sqrt{e^{a \cdot x} - 1} \cdot \sqrt{e^{a \cdot x} - 1} \le 0.0054314674489082245:\\
\;\;\;\;\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(\left(a \cdot x\right) \cdot \frac{1}{6} + \frac{1}{2}\right) + a \cdot x\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{e^{a \cdot x} - 1}\right)\\
\end{array}\]
Target
| Original | 29.4 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.6 |
|---|
\[\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 (* (sqrt (- (exp (* a x)) 1)) (sqrt (- (exp (* a x)) 1))) < 0.0054314674489082245
Initial program 45.0
\[e^{a \cdot x} - 1\]
Taylor expanded around 0 12.7
\[\leadsto \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)}\]
Applied simplify0.1
\[\leadsto \color{blue}{\left(\left(a \cdot x\right) \cdot \left(a \cdot x\right)\right) \cdot \left(\left(a \cdot x\right) \cdot \frac{1}{6} + \frac{1}{2}\right) + a \cdot x}\]
if 0.0054314674489082245 < (* (sqrt (- (exp (* a x)) 1)) (sqrt (- (exp (* a x)) 1)))
Initial program 1.3
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-log-exp1.6
\[\leadsto \color{blue}{\log \left(e^{e^{a \cdot x} - 1}\right)}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed '#(1070833653 108281690 3330367898 3632331308 3494323072 43156186)'
(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))