Average Error: 10.0 → 0.1
Time: 23.9s
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{\frac{2}{x}}{{x}^2} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right)\\
\mathbf{if}\;x \le 3.570692152999792:\\
\;\;\;\;\left(-2\right) \cdot \left(x + \left({x}^3 + \frac{1}{x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2}{x}}{{x}^2} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\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}\]
- Using strategy
rm
Applied add-cube-cbrt 19.9
\[\leadsto \color{blue}{{\left(\sqrt[3]{\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}}\right)}^3}\]
Applied taylor 1.0
\[\leadsto {\left(\sqrt[3]{2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)}\right)}^3\]
Taylor expanded around inf 1.0
\[\leadsto {\left(\sqrt[3]{\color{blue}{2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)}}\right)}^3\]
Applied simplify 0.1
\[\leadsto \color{blue}{\frac{\frac{2}{x}}{x \cdot x} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right)}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\frac{\frac{2}{x}}{{x}^2}} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\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(-2\right) \cdot \left(x + \left({x}^3 + \frac{1}{x}\right)\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))))