Hello

Something I do not understand : the title of your post is "differentiating" and you want to integrate -ln|cos(x)|+k ?

I think that you want to differentiate -ln|cos(x)|+k

Differentiating ln(u(x)) gives u'(x) / u(x)

Here it gives sin(x)/cos(x) = tan(x)