Average Error: 29.7 → 0.4
Time: 1.1m
Precision: 64
Internal Precision: 1344
\[e^{a \cdot x} - 1\]
↓
\[\begin{array}{l}
\mathbf{if}\;\sqrt[3]{{\left(e^{\log \left(e^{x \cdot a} - 1\right)}\right)}^{3}} \le 0.006577663290784691:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt[3]{\left(e^{x \cdot a} - 1\right) \cdot \left(e^{x \cdot a} - 1\right)} \cdot \sqrt[3]{e^{x \cdot a} - 1}\\
\end{array}\]
Try it out
Enter valid numbers for all inputs
Target
| Original | 29.7 |
|---|
| Target | 0.2 |
|---|
| Herbie | 0.4 |
|---|
\[\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 (cbrt (pow (exp (log (- (exp (* x a)) 1))) 3)) < 0.006577663290784691
Initial program 44.8
\[e^{a \cdot x} - 1\]
Taylor expanded around 0 13.0
\[\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.006577663290784691 < (cbrt (pow (exp (log (- (exp (* x a)) 1))) 3))
Initial program 1.0
\[e^{a \cdot x} - 1\]
- Using strategy
rm Applied add-cbrt-cube1.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 simplify1.1
\[\leadsto \sqrt[3]{\color{blue}{{\left(e^{x \cdot a} - 1\right)}^{3}}}\]
- Using strategy
rm Applied unpow31.1
\[\leadsto \sqrt[3]{\color{blue}{\left(\left(e^{x \cdot a} - 1\right) \cdot \left(e^{x \cdot a} - 1\right)\right) \cdot \left(e^{x \cdot a} - 1\right)}}\]
Applied cbrt-prod1.1
\[\leadsto \color{blue}{\sqrt[3]{\left(e^{x \cdot a} - 1\right) \cdot \left(e^{x \cdot a} - 1\right)} \cdot \sqrt[3]{e^{x \cdot a} - 1}}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed 2018170
(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))