Average Error: 14.0 → 0.0
Time: 30.9s
Precision: 64
Internal precision: 896
\[\frac{1}{x + 1} - \frac{1}{x}\]
⬇
\[\begin{array}{l}
\mathbf{if}\;x \le -209135036385.79047:\\
\;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right)\\
\mathbf{if}\;x \le 290639.63932394225:\\
\;\;\;\;\frac{x - \left(1 + x\right)}{\left(x + 1\right) \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{\left(-2\right)} + \frac{1}{{x}^{4}}\right)\\
\end{array}\]
Derivation
- Split input into 2 regimes.
-
if x < -209135036385.79047 or 290639.63932394225 < x
Initial program 28.4
\[\frac{1}{x + 1} - \frac{1}{x}\]
Applied taylor 0.8
\[\leadsto \frac{1}{{x}^{3}} - \left(\frac{1}{{x}^2} + \frac{1}{{x}^{4}}\right)\]
Taylor expanded around inf 0.8
\[\leadsto \color{blue}{\frac{1}{{x}^{3}} - \left(\frac{1}{{x}^2} + \frac{1}{{x}^{4}}\right)}\]
- Using strategy
rm
Applied pow2 0.8
\[\leadsto \frac{1}{{x}^{3}} - \left(\frac{1}{\color{blue}{{x}^{2}}} + \frac{1}{{x}^{4}}\right)\]
Applied pow-flip 0.0
\[\leadsto \frac{1}{{x}^{3}} - \left(\color{blue}{{x}^{\left(-2\right)}} + \frac{1}{{x}^{4}}\right)\]
if -209135036385.79047 < x < 290639.63932394225
Initial program 0.4
\[\frac{1}{x + 1} - \frac{1}{x}\]
- Using strategy
rm
Applied frac-sub 0.0
\[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
Applied simplify 0.0
\[\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 shell --seed '#(772101555 1905824529 294602591 2478279198 2123125427 4197813737)'
(FPCore (x)
:name "2frac (problem 3.3.1)"
(- (/ 1 (+ x 1)) (/ 1 x)))