We have a "fraction" which we wish to differentiate, so we use the quotient rule with u=sin(x) and v=cos(x).
This means that d/dx of u/v = (vdu/dx - udv/dx)/(v^2).
We have u=sin(x) so du/dx= cos(x).
We have v=cos(x) so dv/dx=-sin(x).
Substitutiong these into the quotient rule formula, we get:
dz/dx = (cos(x)*cos(x) - sin(x)(-sin(x)))/(cos^2(x)).
Double negative in the numerator gives a positive, i.e.
(cos(x)*cos(x) + sin(x)sin(x))/(cos^2(x)).
(cos^2(x) + sin^2(x))/(cos^2(x)).
Now we use the trig identity cos^2(x) + sin^2(x) = 1 to get
dz/dx = 1/cos^2(x)
which we know is the same as sec^2(x) since 1/cos(x) = sec(x).
Therefore dz/dx = sec^2(x).