There are two possible answers depending upon what you mean by “first principles.”
1) If by first principles, you mean using derivatives we have already found (like the derivative of y = sin x and y = cos x) and rules we already know (like the quotient rule) this is relatively straightforward.
We know from trigonometry that ##y = tan(x) = (sin(x)) / (cos(x))##
Now we find the derivative of this expression using the :
##y’ = ((cos(x) * cos(x) – sin(x) * (-sin(x)))/(cos^2(x)))##
##y’=(cos^2(x)+sin^2(x))/(cos^2(x))##
##y’ = 1/(cos^2(x)) = sec^2(x)##
2) If by first principles, you mean that you would like to go back to the definition of the derivative, then we have to do a bit more work.
##y’ = lim_(h rarr0)((tan(x+h)-tanx)/h)##
##y’ = lim_(h rarr0)((((tanx+tan h)/(1-tanx*tan h))-tanx)/h)## using the identity for tan (a + b) from trigonometry
##= lim_(h rarr0)(((tanx+tan h-tanx+tan^2(x)tan h)/(1-tanxtan h))/h)##
##= lim_(h rarr0)((tan h+tan^2xtan h)/(h*(1-tanxtan h)))##
##= lim_(h rarr0)(1+tan^2x)/(1-tanxtan h)*cancel(lim_(h rarr0) tan h/h)^(1)##
Note that ##lim_(hrarr0)(tan h/h)=1## because
##lim_(hrarr0)(tan h/h)##=##lim_(hrarr0)(sin h/(cos h*h))##=
##lim_(hrarr0)(sin h/h)*lim_(hrarr0)(1/cos h)##
=1*1=1 (the first limit is a famous one, proven by the squeeze theorem) that you probably learned in your calculus class, while the second limit can be found by simply substituting zero for h)
= ##lim_(hrarr0) (1+tan^2x)/(1-tanx*0)##
##= 1+tan^2x= sec^2x##