$$\lim_{x\rightarrow 0}\frac{e^{x^2}-\ln(1+x^2)-1}{\cos2x+2x\sin x-1}$$
Using Maclaurin's expansion for the numerator gives:
$$\left(1+x^2\cdots\right)-\left(x^2-\frac{x^4}{2}\cdots\right)-1$$
And the denominator:
$$\left(1-2x^2\cdots\right) + \left(2x^2-\frac{x^4}{3}\cdots\right)-1$$
$$\therefore \lim_{x\rightarrow 0} f(x) = \frac{-\dfrac{x^4}{2}}{-\dfrac{x^4}{3}} = \frac{3}{2}$$
But Wolfram gives that the limit is $3$.
I thought, maybe I used too few terms. What is a thumb rule for how many terms in expansion to use to calculate limits?
Using three terms yielded the answer $\lim_{x\rightarrow 0}f(x) = -4$.
What did I do wrong?
Let's begin by writing out some of the expansions.
$$ \begin{align} e^{x^2} &= 1 + x^2 + \frac{x^4}{2} + \frac{x^6}{6!} + \cdots \\ \ln(1 + x^2) &= x^2 - \frac{x^4}{2} + \frac{x^6}{3} + \cdots \\ \cos(2x) &= 1 - \frac{4x^2}{2} + \frac{16x^4}{4!} - \frac{64x^6}{6!} + \cdots \\ 2x\sin x &= 2x^2 - \frac{2x^4}{3!} + \frac{2x^6}{5!} + \ldots \end{align}$$
We will see in a moment if we need more or fewer terms. Then the numerator looks like $$\begin{align} e^{x^2} - \ln(1 + x^2) - 1 &\approx \left( 1 + x^2 + \frac{x^4}{2} + \color{#BB0000}{\frac{x^6}{4!}}\right) - \left( 1 + x^2 - \frac{x^4}{2} + \color{#BB0000}{\frac{x^6}{3}}\right) \\ &\approx x^4 +\color{#BB0000}{\left( \frac{1}{4!} - \frac{1}{3}\right)x^6}, \end{align}$$ which is slightly different than what I said in the comments because I unknowingly dropped a negative sign. In black is the lowest number of coefficients that will matter, but I'm keeping extras in red so that we can better understand how many are necessary.
Similarly, the denominator will look like $$\begin{align} \cos 2x + 2x\sin x - 1 &\approx \left(\frac{-4x^2}{2} + \frac{16x^4}{4!} - \color{#BB0000}{\frac{64x^6}{6!}}\right) + \left(2x^2 - \frac{2x^4}{3!} + \color{#BB0000}{\frac{2x^6}{5!}}\right) \\ &\approx \frac{1}{3}x^4 + \color{#BB0000}{\left(\frac{2}{5!} - \frac{64}{6!}\right)x^6}. \end{align}$$ Putting this all together, your fraction looks a lot like $$ \lim_{x \to 0}\frac{x^4 +\color{#BB0000}{\left( \frac{1}{4!} - \frac{1}{3}\right)x^6}}{\frac{1}{3}x^4 + \color{#BB0000}{\left(\frac{2}{5!} - \frac{64}{6!}\right)x^6}}.$$ We can factor out $x^4$ from the numerator and the denominator, leaving us with $$ \lim_{x \to 0} \frac{1 + \color{#BB0000}{\left( \frac{1}{4!} - \frac{1}{3}\right)x^2}}{\frac{1}{3} + \color{#BB0000}{\left(\frac{2}{5!} - \frac{64}{6!}\right)x^2}} = 3.$$ In this last form, you can see that everything in $\color{#BB0000}{\text{red}}$ doesn't contribute, since it all goes to $0$ as $x \to 0$. Similarly, if we included many more terms, they would all have even higher powers of $x$, and thus go to $0$ as well.
So we see that we needed to go up to degree $4$ approximations everywhere to get the answer. Why degree $4$? Because that is how many contribute to the final answer. A general rule is that you can't go wrong by including too many terms, but you can go wrong if you include too few. $\diamondsuit$