Finding the derivatives using limits. What to do when you have a limit inside a limt I was trying to prove the second derivative formula using limits
\begin{align}f'(x) &= \lim_{h\rightarrow 0}\dfrac{f(x+h)-f(x)}{h} \\f''(x) &= \lim_{h\rightarrow 0}\dfrac{f'(x+h)-f'(x)}{h} \\ &= \lim_{h\rightarrow 0}\dfrac{\lim_{h\rightarrow 0}\dfrac{f(x+2h)-f(x+h)}{h}-\lim_{h\rightarrow 0}\dfrac{f(x+h)-f(x)}{h}}{h} 
\end{align}
However I'm not sure how to go about simplifying this as there is a limit inside of another limit. Does the limit inside nullify as they both tend to zero? If yes, what exactly is the logic behind this and are there any underlying assumptions?
 A: The second derivative is defined in terms of the first derivative.
Say you have $f:D \subset \mathbb{R} \rightarrow \mathbb{R}$ and for every $x \in \mathring{D}$ we define $f'(x)$ as you did. (If you're not familiar with $\mathring{D}$, it means the interior of $D$, namely the set of points that have an open interval around them which is also contained in $D$. We do this because it doesn't really make sense to measure rate of change at points in the domain which are "isolated"). However, for a fixed point $x$, the limit in the definition of $f'(x)$ doesn't have to exist (in fact more often than not it doesn't, and in that case the function isn't differentiable **at that point; take for example the function $x \rightarrow \left\lvert x \right\rvert$. The limit exists at every point $x \neq 0$, but doesn't at $x=0$).
Now, take the set of all points for which this limit exists i.e. let $E := \left\lbrace x \in D : f'(x) \mathrm{ exists} \right\rbrace$. Now, for every $x \in \mathring{E}$, we can define $\displaystyle f''(x):=\lim_{h \rightarrow 0} \frac{f'(x+h)-f'(x)}{h}$. In this definition, $f''(x)$ is simply treated as the standard derivative of the function f', which for every $x \in E$ gives you the output $f'(x)$. Again, $f''(x)$ might not exists for some (or any) $x \in E$. The difference between this and your definition of $f''(x)$ is subtle but crucial:
what your second definition is saying is: (for $x \in D$) first take the limits $\lim_{h\rightarrow 0}\dfrac{f(x+2h)-f(x+h)}{h}$ and $\lim_{h\rightarrow 0}\dfrac{f(x+h)-f(x)}{h}$; since $x$ is fixed, you'll get two constants which both happen to be $f'(x)$, so they will indeed subtract to $0$ and so you'll get in your definition $f''(x)=\displaystyle \lim_{h \rightarrow 0} \frac{0}{h} = 0$; hence you'd get that the second derivative is $0$ at every point for every function, which certainly isn't the case.
A: What you have done is almost fine but you should use different symbols for different limit operators like $$f''(a) =\lim_{h\to 0}\dfrac{\lim_{k\to 0}\dfrac{f(a+h+k)-f(a+h)}{k}-\lim_{l\to 0}\dfrac{f(a+l)-f(a)}{l}}{h}$$ However if you are trying to achieve a definition of $f''$ solely in terms of $f$ as a sort of complicated limit then that's not going to work.
Why?? Lets understand the requirements of the definition of derivative as a limit. As a pre-requisite we must have $f$ defined in a certain neighborhood of $a$ so that the expression under limit used for $f'(a) $ makes sense. Thus in order to define $f''(a) $ we must have $f' $ defined in some neighborhood of $a$. Now that requirement can not be met using any definition like $$f''(a) =\lim_{h\to 0}g(a,h)$$ because we are essentially dealing with just the neighborhood of $a$ and it can not guarantee us anything about the behavior of a function at points other than $a$.
