Confusion about what variable to derive with respect to with L'Hopital's rule In my textbook there are these two examples of applying L'Hopital's rule: 
 
and

In both of them it says to treat $x$ as a constant and the other letter as the variable. I'm used to $x$ being the variable and don't understand why it's being treated as a constant.
I had a search around and found this question asked here but am still confused. After having a read it's my understanding that what's changing is the variable, which I make sense of for the second example since $h$ is approaching zero, but in the first one $x$ is approaching $a$ so I'd have thought that $x$ would be the variable.
 A: In the usual definition of limit the value at the right side of the arrow (as in $\to c$) is a fixed limit point of the domain of the function , this means that it is a constant. The variable stay at the left side of the arrow (as the $x$  in $x\to c$) and, applying L'Hopital rule we have to derive with respect to this variable.
So, the notation in your first example is really confusing. It is better to note that in the limit
$$
\lim_{x\to a}\frac{f(x)-f(a)}{x-a}
$$
there is aperfect symmetry between $x$ and $a$ so that we can write it as:
$$
\lim_{a\to x}\frac{f(a)-f(x)}{a-x}
$$
and use L'Hopital rule (deriving with respect to $a$) to find
$$
\lim_{a\to x}\frac{f(a)-f(x)}{a-x}=\frac{f'(x)}{1}
$$
In your second example the fact that $h$ is the variable is clear in the fact that the limit is for $h \to 0$.
A: In the first example, $x$ is the variable and $a$ is constant, as it's apparent from the fact that $f(x)-f(a)$ becomes $f'(x)$.
One should note that this indeed allows to compute the derivative at $a$ provided


*

*$f$ is continuous at $a$;

*$\lim\limits_{x\to a}f'(x)$ exists.
Here's an example where 2 fails: define $f(x)=x^2\sin(1/x)$ for $x\ne0$ and $f(0)=0$. The function is continuous and differentiable at $0$ (checked directly), but, for $x\ne0$,
$$
f'(x)=2x\sin\frac{1}{x}-\cos\frac{1}{x}
$$
which has no limit for $x\to0$.
An example where 1 fails. Define $f(x)=0$ for $x\ne0$ and $f(0)=1$. Then $\lim_{x\to0}f'(x)=0$, but $f$ is not differentiable at $0$.
This should be a reminder not to apply blindly l’Hôpital.
In this case, we're using a much weaker form of the theorem. Suppose $f$ and $g$ are differentiable at $a$ and $g'(a)\ne0$. Then
$$
\lim_{x\to a}\frac{f(x)-f(a)}{g(x)-g(a)}=\frac{f'(a)}{g'(a)}
$$
Indeed, this just requires rewriting the limit as
$$
\lim_{x\to a}
\frac{\;\dfrac{f(x)-f(a)}{x-a}\;}
     {\dfrac{g(x)-g(a)}{x-a}}
$$
and applying the theorem on limit of quotients. The full l’Hôpital’s theorem doesn't even require $f$ and $g$ being differentiable at $a$ (but of course has other requirements).

In the second example, $h$ is the variable; if you aren't comfortable with $x$ being constant, change it into $a$ or whatever.
The fully spelled out hypotheses are that $f$ is twice differentiable in a neighborhood of $x$ and the second derivative is continuous at $x$. In particular, the existence of the second derivative in a neighborhood of $x$ implies that $f'$ is continuous (being differentiable) in that neighborhood.
Using the above example with $x^2\sin(1/x)$ one could build an example of a function which is twice differentiable everywhere, but the second derivative fails to be continuous at $0$.
