Average Error: 14.5 → 0.3
Time: 22.1s
Precision: 64
Internal precision: 128
\[\frac{1}{x + 1} - \frac{1}{x}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -3833755296400741.5:\\
\;\;\;\;\frac{\frac{1}{x}}{{x}^2} - \frac{\frac{1}{x}}{x}\\
\mathbf{if}\;x \le 9.757059776157302 \cdot 10^{+20}:\\
\;\;\;\;\frac{x - \left(1 + x\right)}{\left(x + 1\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{{x}^2} - \frac{\frac{1}{x}}{x}\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if x < -3833755296400741.5 or 9.757059776157302e+20 < x
Initial program 29.0
\[\frac{1}{x + 1} - \frac{1}{x}\]
Applied taylor 29.0
\[\leadsto \left(\left(\frac{1}{x} + \frac{1}{{x}^{3}}\right) - \frac{1}{{x}^2}\right) - \frac{1}{x}\]
Taylor expanded around inf 29.0
\[\leadsto \color{blue}{\left(\left(\frac{1}{x} + \frac{1}{{x}^{3}}\right) - \frac{1}{{x}^2}\right)} - \frac{1}{x}\]
Applied simplify 0.1
\[\leadsto \color{blue}{\frac{\frac{1}{x}}{{x}^2} - \frac{\frac{1}{x}}{x}}\]
if -3833755296400741.5 < x < 9.757059776157302e+20
Initial program 1.5
\[\frac{1}{x + 1} - \frac{1}{x}\]
- Using strategy
rm
Applied frac-sub 0.4
\[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
Applied simplify 0.4
\[\leadsto \frac{\color{blue}{x - \left(1 + x\right)}}{\left(x + 1\right) \cdot x}\]
- Recombined 2 regimes into one program.
- Removed slow pow expressions
Runtime
Please include this information when filing a bug report:
herbie --seed '#(919572473 3678994413 1766500800 3475007827 3190906205 2374886118)'
(FPCore (x)
:name "2frac (problem 3.3.1)"
(- (/ 1 (+ x 1)) (/ 1 x)))