Limits using Maclaurins expansion for $\lim_{x\rightarrow 0}\frac{e^{x^2}-\ln(1+x^2)-1}{\cos2x+2x\sin x-1}$ $$\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?
 A: 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$
A: In a case where $x \to 0$ as here, if the two expansions of top and bottom happen to start with the same degree, the limit is the ratio of the coefficients. Here, the top expansion starts with $x^4$ while the bottom starts with $x^4/3$ making the limit $3.$
That is, we have 
$$\frac{x^4+\cdots}{x^4/3+\cdots},$$
and when top and bottom are divided by $x^4$ the top becomes $1$ plus terms going to zero, while the bottom becomes $1/3$ plus terms going to zero, as $x\to 0.$
[note there are some signs to keep track of, in seeing that each of top and bottom actually start out with a nonzero fourth power.]
A: Doing almost the same as mixedmath, I have very slightly different results since 
$$e^{x^2} = 1+x^2+\frac{x^4}{2}+\frac{x^6}{6}+\frac{x^8}{24}+O\left(x^9\right) $$
$$\ln(1 + x^2) = x^2-\frac{x^4}{2}+\frac{x^6}{3}-\frac{x^8}{4}+O\left(x^9\right)$$
$$\cos(2x)=1-2 x^2+\frac{2 x^4}{3}-\frac{4 x^6}{45}+\frac{2 x^8}{315}+O\left(x^9\right)$$
$$2x\sin x =2 x^2-\frac{x^4}{3}+\frac{x^6}{60}-\frac{x^8}{2520}+O\left(x^9\right)$$ So, for the numerator, $$x^4-\frac{x^6}{6}+\frac{7 x^8}{24}+O\left(x^9\right)$$ and for the denominator $$\frac{x^4}{3}-\frac{13 x^6}{180}+\frac{x^8}{168}+O\left(x^9\right)$$ Performing the long division $$\frac{e^{x^2}-\log \left(x^2+1\right)-1}{2 x \sin (x)+\cos (2 x)-1}\approx 3+\frac{3 x^2}{20}+\cdots$$ For sure, the limit is the same, but pushing the expansion a little bit allows to see how is this limit approached.
If you push a little more the expansions, you should find that $$\frac{e^{x^2}-\log \left(x^2+1\right)-1}{2 x \sin (x)+\cos (2 x)-1}\approx 3+\frac{3 x^2}{20}+\frac{2391 x^4}{2800}+\cdots$$ and you should be amazed to see how this approximation is close to the expression (just for curiosity, graph on the same plot the function and this last approximation for $-1 \leq x \leq 1$).
