Solution (source code)

= Solution

Combine the two singular terms before taking the <limit>:
$$
\frac{\log(1+x)}{x^2}-\frac1x=\frac{\log(1+x)-x}{x^2}.
$$
For $x$ near zero, within the real domain $x>-1$, the <Maclaurin series> is $\log(1+x)=x-x^2/2+O(x^3)$. Hence
$$
\frac{\log(1+x)-x}{x^2}=-\frac12+O(x),\qquad\boxed{\lim_{x\to0}\left(\frac{\log(1+x)}{x^2}-\frac1x\right)=-\frac12}.
$$
The two individual terms have divergent limits; their leading singularities cancel. Evaluating them separately as an “infinity minus infinity” subtraction would not justify the finite result.