The derivative of $ \tan x$ is $ \sec^2 x$. Why? I understand why the derivative of $\sin x$ is $\cos x$, and why the derivative of $\cos x$ is $-\sin x$ in a geometric way. 

But I can not understand why the derivative of $\tan x$ is $\sec^2 x$. 

Can someone please explain this in a visual, geometric way using the unit circle?
The following is maybe a little bit hand-wavy, but the idea is hopefully clear.

If $\theta$ is the angle $EAH$ in the figure, then $\tan \theta$ is the lenght of the segment $BC$. If we increase that angle slightly (or “infinitesimally”), then the segment $EF$ is approximately $d\theta$, and we would like to know the length of $CD$, since that's the change in $\tan \theta$.

Since the triangle $AHE$ is $\cos \theta$ times smaller than the triangle $ABC$, the segment $EF$ is $\cos \theta$ times shorter than $CG$. And $CG$ is in turn $\cos \theta$ times shorter than $CD$ (similar triangles; the angle $GCD$ is $\theta$ and the angle $CGD$ is $\pi/2$ up to an infinitesimal correction). So $EF$ is $\cos^2 \theta$ times shorter than $CD$, and thus
$$
d( \tan\theta ) = CD = \frac{EF}{\cos^2\theta} = \frac{d\theta}{\cos^2 \theta}
.
$$
I can't explain it geometrically, but I can prove it algebraically:

$$\begin{aligned}
\frac{d}{dx} [\tan x] &amp;= \frac{d}{dx} \left[\frac{\sin x}{\cos x} \right] &amp;\quad \text{Definition of } \tan x\\ &amp;= \frac{\frac{d}{dx}[\sin x]\cdot (\cos x) - (\sin x) \cdot \frac{d}{dx} \left[\cos x \right]}{\cos^2 x} &amp;\quad \text{Quotient Rule}\\ &amp;= \frac{\cos^2 x + \sin^2x }{\cos^2 x} &amp;\quad \text{Derivatives of } \sin x \text{ and } \cos x \\ &amp;= {\frac{1}{\cos^2x}} &amp;\quad \text{Pythagorean Identity} \\ &amp;= {\sec^2 x}  &amp;
\end{aligned}$$