u need to break up the function before differenciating, as below,
y= { 1/sinx if x lies between 0 and pi}
and
{-1/sinx if x lies between pi and 2pi}
so, dy/dx = { -cotx.cosecx if x lies between 0 and pi}
and
{cotx.cosecx if x lies between pi and 2pi}
so for every mod function, first make cases acc. to domain and only then differenciate it. Here, i haven't taken the general value for x, but u modify it for any general value.
hope u got it!!
{plz do rate me if u find it useful}