If $\lim_{x\to 0}\frac{\cos^2x-\cos x-e^x\cos x+e^x-\frac{x^3}{2}}{x^n}$ is a non zero finite number number, find $n$ where $n\in\mathbb{N}$ 
If the following limit $$\lim_{x\to 0}\frac{\cos^2x-\cos x-e^x\cos x+e^x-\frac{x^3}{2}}{x^n}$$
  is a non zero finite number number, find $n$ where $n\in\mathbb{N}$

$$\lim_{x\to 0}\frac{\cos^2x-\cos x-e^x\cos x+e^x-\frac{x^3}{2}}{x^n}=\lim_{x\to 0}\frac{(\cos x-e^x)(\cos x-1)-\frac{x^3}{2}}{x^n}=\lim_{x\to 0}\frac{x^2(\cos x-e^x)\frac{(\cos x-1)}{x^2}-\frac{x^3}{2}}{x^n}$$
Since $\lim_{x\to 0}\frac{(\cos x-1)}{x^2}=-\frac{1}{2}$
$$\implies \lim_{x\to 0}\frac{x^2(\cos x-e^x)\frac{(\cos x-1)}{x^2}-\frac{x^3}{2}}{x^n}=\lim_{x\to 0}\frac{-\frac{x^2}{2}(\cos x-e^x)-\frac{x^3}{2}}{x^n}$$
Since $\cos x$ is $1$ when $x$ tends to zero,
$$\lim_{x\to 0}\frac{-\frac{x^2}{2}(\cos x-e^x)-\frac{x^3}{2}}{x^n}=\lim_{x\to 0}\frac{-\frac{x^2}{2}(1-e^x)-\frac{x^3}{2}}{x^n}$$
Since $\frac{1-e^x}{x}$ tends to $-1$ when $x\to 0$, 
$$\lim_{x\to 0}\frac{-\frac{x^2}{2}(1-e^x)-\frac{x^3}{2}}{x^n}=\lim_{x\to 0}\frac{\frac{x^2}{2}x-\frac{x^3}{2}}{x^n}$$
Isnt the answer $n=3$? Answer given is $n=4$

Taylor series of $\cos^2 x - \cos x - e^x \cos x + e^x$ is
$$\frac{x^3}{2}+\frac{x^4}{2}+O(x^5)$$
Therefore,
$$\lim_{x \to 0} \frac{\cos^2 x - \cos x - e^x \cos x + e^x - \frac{x^3}{2}}{x^n} = \lim_{x \to 0} \frac{\frac{x^4}{2} + O(x^5)}{x^n}$$
If $n = 3$, the limit goes to 0, but it is given that the limit is non-zero finite. Therefore $n = 4$.
