Average Error: 10.5 → 0.2
Time: 33.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 -7.829158115972637 \cdot 10^{-05}:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{x \cdot x}\right)\\
\mathbf{if}\;x \le 849008901.3057916:\\
\;\;\;\;\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{\frac{2}{x}}{x \cdot x}\right)\\
\end{array}\]
Target
| Original | 10.5 |
| Comparison | 0.5 |
| Herbie | 0.2 |
\[ \frac{2}{x \cdot \left({x}^2 - 1\right)} \]
Derivation
- Split input into 3 regimes.
-
if x < -7.829158115972637e-05
Initial program 20.3
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
Applied taylor 0.4
\[\leadsto 2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{7}}\right)\]
Taylor expanded around inf 0.4
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{7}}\right)}\]
Applied simplify 0.5
\[\leadsto \color{blue}{\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^3}\right)}\]
- Using strategy
rm
Applied cube-mult 0.5
\[\leadsto \frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{2}{\color{blue}{x \cdot \left(x \cdot x\right)}}\right)\]
Applied associate-/r* 0.1
\[\leadsto \frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \color{blue}{\frac{\frac{2}{x}}{x \cdot x}}\right)\]
if -7.829158115972637e-05 < x < 849008901.3057916
Initial program 0.4
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
if 849008901.3057916 < x
Initial program 20.1
\[\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}^{3}} + 2 \cdot \frac{1}{{x}^{7}}\right)\]
Taylor expanded around inf 0.6
\[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{5}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{7}}\right)}\]
Applied simplify 0.6
\[\leadsto \color{blue}{\frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{2}{{x}^3}\right)}\]
- Using strategy
rm
Applied cube-mult 0.6
\[\leadsto \frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \frac{2}{\color{blue}{x \cdot \left(x \cdot x\right)}}\right)\]
Applied associate-/r* 0.1
\[\leadsto \frac{2}{{x}^{7}} + \left(\frac{2}{{x}^{5}} + \color{blue}{\frac{\frac{2}{x}}{x \cdot x}}\right)\]
- Recombined 3 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(3471149495 3637450564 1157587775 928512618 464264894 3809688197)'
(FPCore (x)
:name "NMSE problem 3.3.3"
:target
(/ 2 (* x (- (sqr x) 1)))
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))