<s>[INST] Is $\tan(x)$ differentiable for $x\in ( -\pi/2 , \pi/2 )$ This is an assignment question and in class we taught the definition that:

A function $f(x)$ is differentiable if we can find $f(x+h) - f(x) = Kh +h E(x,h)$, where $K=f'(x)$ and $E(x,h) \rightarrow 0$   as $h \rightarrow 0$
E.g. $f(x) = x^3 \Rightarrow f(x+h) - f(x) = (x+h)^3 - x^3 = 3x^2h+2xh^2 +h^3$
  and so $3x^2h+2xh^2+h^3 =Kh +h E(x,h) $. Thus we can conclude that $K = 3x^2$ and $E(x,h) = 2xh + h^2 $, and thus $f$ is differentiable since $E(x,h) = 2xh + h^2 \rightarrow 0$   as $h \rightarrow 0$

But for proving that $tan(x)$ is differentiable I started and got stuck:
$\tan(x+h) - \tan(x) = \dfrac{\tan(h)(1+\tan^2(x))}{1-\tan(x)\tan(h)}$, I really want to find $K = 1+ \tan^2(x)$ but I can't find a way to get $(1+\tan^2(x))h$ without a fraction term, and $E(x,h) = 0 , h \rightarrow 0$.
Any hints or help would be great, thanks.
 [/INST] We can get our hands dirty with more trig identities:
\begin{align*}
\frac{(\tan h)(1+\tan^2 x)}{1-\tan x\tan h}
&= \frac{\frac{\sin h}{\cos h}(\sec^2 x)}{1 - \frac{\sin x\sin h}{\cos x \cos h}} \cdot \frac{\cos x \cos h}{\cos x \cos h} \\
&= \frac{(\sin h)(\sec^2 x)(\frac{1}{\sec x})}{\cos x \cos h - \sin x\sin h} \\
&= \frac{\sin h \sec x}{\cos(x + h)} \\
&= \sin h \sec x \sec (x + h) \\
\end{align*}
Dividing this expression by $h$ and taking the limit as $h \to 0$, we obtain:
$$
\frac{d}{dx}\tan x = \left[\lim_{h \to 0} \frac{\sin h}{h} \right] \cdot \left[\lim_{h \to 0} \sec{x}\sec(x + h)\right] = 1 \cdot \sec x \sec(x + 0) = \sec^2x
$$
as desired.
</s>