Average Error: 9.9 → 0.3
Time: 46.0s
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 -17360.73116012661:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^3} + \frac{2}{{x}^{5}}\right)\\
\mathbf{if}\;x \le 151370699.13763306:\\
\;\;\;\;\frac{\left(\left(x - 2\right) - 2 \cdot x\right) \cdot \left(x - 1\right) + \left(x + x \cdot x\right)}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^3} + \frac{2}{{x}^{5}}\right)\\
\end{array}\]
Target
| Original | 9.9 |
| Comparison | 0.2 |
| Herbie | 0.3 |
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]
Derivation
- Split input into 2 regimes.
-
if x < -17360.73116012661 or 151370699.13763306 < x
Initial program 19.8
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.5
\[\leadsto 2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{7}} + 2 \cdot \frac{1}{{x}^{5}}\right)\]
Taylor expanded around inf 0.5
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{3}} + \left(2 \cdot \frac{1}{{x}^{7}} + 2 \cdot \frac{1}{{x}^{5}}\right)}\]
Applied simplify 0.5
\[\leadsto \color{blue}{\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^3} + \frac{2}{{x}^{5}}\right)}\]
if -17360.73116012661 < x < 151370699.13763306
Initial program 0.4
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
- Using strategy
rm
Applied frac-sub 0.4
\[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
Applied frac-add 0.1
\[\leadsto \color{blue}{\frac{\left(1 \cdot x - \left(x + 1\right) \cdot 2\right) \cdot \left(x - 1\right) + \left(\left(x + 1\right) \cdot x\right) \cdot 1}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}}\]
Applied simplify 0.1
\[\leadsto \frac{\color{blue}{\left(\left(x - 2\right) - 2 \cdot x\right) \cdot \left(x - 1\right) + \left(x + x \cdot x\right)}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please report a bug with the following info:
herbie --seed '#(2140466705 3761342866 2084043251 1728887453 1128069928 3759225552)'
(FPCore (x)
:name "NMSE problem 3.3.3"
:target
(/ 2 (* x (- (sqr x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))