l'Hôpital and it's use in derivation In for example $$\lim_{x\rightarrow 0} \frac{e^{ax} - 1 - ax}{1 - \cos x}$$
We would use l'Hôpital rule and derive it twice to get $a^2$
How do you see this when just looking at the given function, when do you know you should use l'Hôpital and can someone give a real simple explanation on why it works?
 A: l'Hopital's rule is for computing the limit of a ratio when the numerator and denominator both approach $\infty$ or $0$ (this is called an indeterminant form). Often after an application of l'Hopital's rule, a simplification of the resulting function will be necessary. Other times, the resulting limit will also be in this indeterminant form.
Specifically l'Hopital's rule states that if $g(x) \to \infty$ and $h(x) \to \infty$ as $x \to a$ (or both going to zero) then $$\lim_{x \to a} \frac{g(x)}{h(x)} = \lim_{x \to a} \frac{g'(x)}{h'(x)}$$ provided both functions are differentiable at $a$.
For example consider $$\lim_{x \to 0} \frac{x^2+x}{x+\sin(x)}$$ as $x \to 0$ we have the indeterminant case of $0/0$. Applying l'Hopital's rule we find:
$$\lim_{x \to 0} \frac{x^2+x}{x+\sin(x)} = \lim_{x \to 0} \frac{2x + 1}{1+\cos(x)} = \frac{1}{2}$$
This can also be applied when $a$ is replaced by $\infty$.
In the specific case that you have presented, we see that $1-\cos(x)$ is zero when $x=0$ and so is $e^{ax}-1-ax$. When we differentiate the top and bottom we see that the new denominator is $\sin(x)$, which is also $0$ at $x=0$. The numerator becomes $ae^{ax}-a$ which is also zero at $x=0$. Seeing this ahead of time just takes experience. When you see a linear term in the numerator, the $-1-ax$, we know that after two differentiations it will dissapear. So we anticipate only having to apply this procedure twice.
$$\lim_{x\to 0} \frac{e^{ax} -1 -ax}{1-\cos(x)} = \lim_{x\to 0} \frac{ae^{ax}-a}{\sin(x)} = \lim_{x\to 0} \frac{a^2 e^{ax}}{\cos(x)} = a^2$$
A: 1)expand the  $e^{ax}$ in the numerator as $ 1+ a x +\frac{(ax)^2}{2} + O((x)^3)$
2) expand the $\cos x$ in the denominator as $1-\frac{x^2}{2} + O(x^4)$
What do you get? 
A: To understand it, let us discuss a simple example. Let $$f(x)=\frac{x^2-ax}{x^3-ax^2+x-a}$$and we wand to get $\lim_{x\to 0}f(x)$. It is clear that the direct substitution give us $\frac{0}{0}$. So we a factor $(x-a)$. We factor out $(x-a)$ and cancel it and then substitute again.
$$f(x)=\frac{x^2-ax}{x^3-ax^2+x-a}=\frac{(x-a)x}{(x-a)(x^2+1)}$$
 In this case the numerator, for example, will be $a$ and if we differentiate it and then substitute we get also $a$. L'Hopital do this step to us in a simple way since its derivative is $h'(x)=2x-a$ and at $x=a$ we have $h'(a)=a$. In general, if the numerator is $h(x)$, then
$$h(a)=0\implies h(x)=(x-a)g(x)=0\\h'(x)=g(x)+(x-a)g'(a)\implies h'(a)=g(a)$$To know when to use it. Just substitute, if you get $\frac00$ this means there is a common factor between top and bottom and you can use it. I hope it helps out
