Average Error: 10.0 → 0.1
Time: 29.5s
Precision: 64
Ground Truth: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -8.658073314327725 \cdot 10^{-05}:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{{x}^2}\right)\\
\mathbf{if}\;x \le 3.570692152999792:\\
\;\;\;\;\left(x + \left({x}^3 + \frac{1}{x}\right)\right) \cdot \left(-2\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{{x}^2}\right)\\
\end{array}\]
Target
| Original | 10.0 |
| Comparison | 0.6 |
| Herbie | 0.1 |
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]
Derivation
- Split input into 2 regimes.
-
if x < -8.658073314327725e-05 or 3.570692152999792 < x
Initial program 19.9
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.6
\[\leadsto 2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{7}} + 2 \cdot \frac{1}{{x}^{3}}\right)\]
Taylor expanded around inf 0.6
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{7}} + 2 \cdot \frac{1}{{x}^{3}}\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{x \cdot x}\right)}\]
Applied simplify 0.1
\[\leadsto \frac{2}{{x}^{7}} + \color{blue}{\left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{{x}^2}\right)}\]
if -8.658073314327725e-05 < x < 3.570692152999792
Initial program 0.1
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.0
\[\leadsto -\left(2 \cdot {x}^{3} + \left(2 \cdot x + 2 \cdot \frac{1}{x}\right)\right)\]
Taylor expanded around 0 0.0
\[\leadsto \color{blue}{-\left(2 \cdot {x}^{3} + \left(2 \cdot x + 2 \cdot \frac{1}{x}\right)\right)}\]
Applied simplify 0.0
\[\leadsto \color{blue}{\left(x + \left({x}^3 + \frac{1}{x}\right)\right) \cdot \left(-2\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(773770014 1796468937 2800673231 3017960497 2849053408 1647740057)'
(FPCore (x)
:name "NMSE problem 3.3.3"
:target
(/ 2 (* x (- (sqr x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))