Average Error: 29.8 → 0.1
Time: 1.0m
Precision: 64
Internal Precision: 1344
\[\left(e^{x} - 2\right) + e^{-x}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \le 0.00361961541110823:\\
\;\;\;\;(\frac{1}{360} \cdot \left({x}^{6}\right) + \left((\left({x}^{4}\right) \cdot \frac{1}{12} + \left(x \cdot x\right))_*\right))_*\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\log \left((\left(2 + e^{x}\right) \cdot \left(\left(e^{x} - 2\right) \cdot e^{x}\right) + \left(2 + e^{x}\right))_*\right)}}{\left(e^{x} + 2\right) \cdot e^{x}}\\
\end{array}\]
Target
| Original | 29.8 |
|---|
| Target | 0.0 |
|---|
| Herbie | 0.1 |
|---|
\[4 \cdot {\left(\sinh \left(\frac{x}{2}\right)\right)}^{2}\]
Derivation
- Split input into 2 regimes
if (+ (- (exp x) 2) (exp (- x))) < 0.00361961541110823
Initial program 30.1
\[\left(e^{x} - 2\right) + e^{-x}\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{{x}^{2} + \left(\frac{1}{360} \cdot {x}^{6} + \frac{1}{12} \cdot {x}^{4}\right)}\]
Applied simplify0.0
\[\leadsto \color{blue}{(\frac{1}{360} \cdot \left({x}^{6}\right) + \left((\left({x}^{4}\right) \cdot \frac{1}{12} + \left(x \cdot x\right))_*\right))_*}\]
if 0.00361961541110823 < (+ (- (exp x) 2) (exp (- x)))
Initial program 1.0
\[\left(e^{x} - 2\right) + e^{-x}\]
- Using strategy
rm Applied exp-neg0.9
\[\leadsto \left(e^{x} - 2\right) + \color{blue}{\frac{1}{e^{x}}}\]
Applied flip--2.8
\[\leadsto \color{blue}{\frac{e^{x} \cdot e^{x} - 2 \cdot 2}{e^{x} + 2}} + \frac{1}{e^{x}}\]
Applied frac-add4.1
\[\leadsto \color{blue}{\frac{\left(e^{x} \cdot e^{x} - 2 \cdot 2\right) \cdot e^{x} + \left(e^{x} + 2\right) \cdot 1}{\left(e^{x} + 2\right) \cdot e^{x}}}\]
Applied simplify3.9
\[\leadsto \frac{\color{blue}{(\left(2 + e^{x}\right) \cdot \left(\left(e^{x} - 2\right) \cdot e^{x}\right) + \left(2 + e^{x}\right))_*}}{\left(e^{x} + 2\right) \cdot e^{x}}\]
- Using strategy
rm Applied add-exp-log4.9
\[\leadsto \frac{\color{blue}{e^{\log \left((\left(2 + e^{x}\right) \cdot \left(\left(e^{x} - 2\right) \cdot e^{x}\right) + \left(2 + e^{x}\right))_*\right)}}}{\left(e^{x} + 2\right) \cdot e^{x}}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed 2020178 +o rules:numerics
(FPCore (x)
:name "exp2 (problem 3.3.7)"
:herbie-target
(* 4 (pow (sinh (/ x 2)) 2))
(+ (- (exp x) 2) (exp (- x))))