Possible Flaw in taking derivatives in a limit I was calculating some limits involving trigonometric functions, but I was stuck in the following limit for a while : $$\lim_{x\to 0} \frac {-\cos^2 x - \cos x + 2 }{x.\sin x} $$
I evaluated it as below:
$$\begin{align} & \lim_{x\to 0} \frac {-\cos^2 x - \cos x + 2 }{x.\sin x}\\
&= \lim_{x\to 0} \frac {\frac {-\cos^2 x - cos x + 2}{x} }{\sin x}\\
&= \lim_{x\to 0} \frac {\frac {\left(-\cos^2 x - \cos x + 2\right) - \left(-\cos^2 0 - \cos 0 + 2\right)}{x - 0} }{\sin x}\\
&= \lim_{x\to 0} \frac {\frac {d}{dx}\left(-\cos^2 x - \cos x + 2\right)  }{\sin x}\\
&= \lim_{x\to 0} \frac {2 \cos x . \sin x + \sin x }{\sin x}\\
&= \lim_{x\to 0} {2 \cos x + 1}\\
&= 3\end {align}$$
But  the correct answer is actually$$\frac 32$$ so I want to know what is the flaw in my work, and is it possible in general to use this trick.. (my exemple may be just an exception).
 A: In short: you cannot say
$$
\lim_{x\to 0} \frac{\frac{f(x)-f(0)}{x-0}}{g(x)} = 
\lim_{x\to 0} \frac{f'(x)}{g(x)}
$$
which is what you used in your third step. This is simply not true in general.

To see this on a simpler example, take e.g. $f$ defined by $f(x)=x^2$ and $g(x)=x$.
Then 
$$
\lim_{x\to 0} \frac{\frac{f(x)-f(0)}{x-0}}{g(x)} = 
\lim_{x\to 0} \frac{\frac{x^2}{x}}{x}
\lim_{x\to 0} 1 = 1
$$
while
$$
\lim_{x\to 0} \frac{f'(x)}{g(x)} = \lim_{x\to 0} \frac{2x}{x} = 2.
$$
A: If the limits exist and the denominator is nonzero, then
$$ \lim_{x \to a} \frac{ \frac{f(x) - f(a)}{x-a} }{g(x) }
= \frac{\lim_{x \to a} \frac{f(x) - f(a)}{x-a}}{\lim_{x \to a} g(x)} $$
and so you could conclude
$$ \lim_{x \to a} \frac{ \frac{f(x) - f(a)}{x-a} }{g(x) } = \frac{f'(a)} {\lim_{x \to a} g(x)}$$
But you are not in that situation, and that's not what you tried to conclude either.
A: You cannot just replace the tangent formula by the derivative ; doing so would mean that you are actually taking the limit when x -> 0, but in that case, you must also divide by $sin(0)$, which you cannot do obviously.
What you should do here is use equivalent functions, namely the following :
$sin(x) \underset{x \rightarrow 0}{=}x + o(x^2)$
$cos(x) \underset{x \rightarrow 0}{=}1 - \frac{x^2}{2} + o(x^3)$
Where $o(x^n)$ is a term that represents negligeable values. Technically speaking, $o(x^n)$ is a non-zero function $g$ so that $\frac{g(x)}{x^n} \underset{x \rightarrow 0}{\rightarrow} 0$. When replacing functions in products or divisions by their equivalents, you can ignore the $o(x^n)$ term, but not when replacing functions in sums or differences. For example, this is true :
$\frac{sin(x)cos(x)}{x} \underset{x \rightarrow 0}{=} \frac{x \times cos(x)}{x} = cos(x) \underset{x \rightarrow 0}{\rightarrow} 1$
But this is false :
$(1 + \frac{1}{n})^n \underset{n \rightarrow \infty}{=} (1 + 0)^n = 1$
In your case, just don't forget to include the negligeable terms when replacing terms of the sum with equivalent functions, and you should be good - remember than squaring is doing a product.
