Here is one way.

Sorry but I forgot already those chain rule, quotient rule, whatever rule. I just keep on differentiating until all the variables are differentiated, etc. I must be following those said rules although those rules are not in my mind any more.

y = [(1 +cosX) / sinX]^(-1)

dy/dX = -1[(1 +cosX) / sinX]^(-2) *({sinX[-sinX] -(1 +cosX)[cosX]} / sin^2(X))

dy/dX = (-1 / [(1 +cosX) / sinX]^2) * ({-sin^2(X) -cosX -cos^2(X)} / sin^2(X))

dy/dX = -(sin^2(X) / (1 +cosX)^2) * -({sin^2(X) +cos^2(X) +cosX} / sin^2(X))

The sin^2(X) cancell out; the sin^2(X) +cos^2(X) is converted to 1; the multiplication of negatives turns to positive,

dy/dX = (1 +cosX) / (1 +cosX)^2

dy/dX = 1 / (1 +cosX) ------------------------answer.

---------------------------------------------------------------

y = sec^2(pi*X)

Or,

y = [sec(pi*x)]^2

dy/dX = 2[sec(pi*X)] *[sec(pi*X)tan(pi*X)] *[pi]

dy/dX = (2pi)sec^2(pi*X)tan(pi*X) -----------------answer.