What is the discrepancy I am facing in $\lim_{x \to 0} \frac{x \sin x}{1- \cos x}$? Take a look at the following limit: I am missing something simple but I'm not being able to get it.
$$\lim_{x \to 0} \dfrac{x \sin x}{1- \cos x}$$
We can write the denominator as $2\sin^2x/2$ and the $\sin x$ above it as $2 \sin x/2\cdot \cos x/2$ which gives:
$$\lim_{x \to 0} \dfrac{x \cos x/2}{\sin x/2}$$
which being in $0/0$ form can be operated using L'Hopital's rule. We differentiate and then get $2$.
But, if we take another approach and directly use that rule in the first step, we get-
$$\lim_{x \to 0} \dfrac{x \cos x + \sin x}{\sin x}$$
Here I tried cancelling the sines which gave-
$$\lim_{x \to 0}x \cot x+1=1$$
I know that the first one is right, but I think I am making a very common mistake people make in limits. Is cancelling the sines a wrong step here? In general, what should I do to calculate these limits so that I don't make these mistakes?
 A: Be careful! In fact, $$\lim_{x \rightarrow 0} x \cot x$$ is also an indeterminant form, so a second application of L'Hopital's rule is necessary: $$\lim_{x \rightarrow 0} \frac{x \cos x + \sin x}{\sin x} = \lim_{x \rightarrow 0} \frac{2 \cos x - x \sin x}{\cos x} = 2$$
I always suggest to try direct substitution. In this case, cot 0 is undefined, so you obtain the indeterminant form $$0 \cdot \cot 0 = 0 \cdot \infty$$ Any time you get an infinity in your answer, you need to be careful.
A: Using your first idea
$$1-\cos(x)=2\sin^2\left(\frac{x}{2}\right).$$
Then $$\frac{x\sin(x)}{2\sin^2(x/2)}=2\cdot \frac{(x/2)^2}{\sin ^2(x/2)}\cdot \frac{\sin(x)}{x}.$$
Using $\sin(x)\sim x$ at $0$ gives the wished answer.

Using your second idea with l'Hospital
You have that \begin{align*}
\lim_{x\to 0}\frac{x\sin(x)}{1-\cos(x)}&=\lim_{x\to 0}\frac{x\cos(x)+\sin(x)}{\sin(x)}\\
&=1+\lim_{x\to 0}\frac{x}{\sin(x)}\cdot \cos(x).
\end{align*}
Using $\sin(x)\sim x$ at $0$, allows you to conclude.

Using Taylor
You have that $\sin(x)=x+o(x)$ and $\cos(x)=1-\frac{x^2}{2}+o(x^2)$
Therefore, $$\frac{x\sin(x)}{1-\cos(x)}=\frac{x^2+o(x^2)}{x^2/2+o(x^2)}=2\cdot \frac{1+o(1)}{1+o(1)}=2+o(1).$$
