First, arctan is an odd function, so rewrite it as -arctan((1-sin(x))/cos(x)).

Since it's an arctan, and that's similar to the half-angle formula for tangent, I'd substitute x = pi/2 - y.

Then (1-sin(x))/cos(x) = (1-cos(y))/sin(y) = tan(y/2)

Then arctan(tan(y/2)) = y/2 + k(pi) for the integer k such that - pi/2 < (y/2 + k(pi)) < pi/2.

That condition is - pi/2 < ((pi/2 - x)/2 + k(pi)) < pi/2, which is (mulitply by 4/pi) -2 < 1 - (2/pi)x +4k < 2, which is

-3/4 < - (1/2 pi)x +k < 1/4, or -3/4 < k - x/(2pi) < 1/4. Thus k between a and a+1, where a = x/(2pi) - 3/4.

Thus arctan((sin(x)-1)/cos(x)) = -arctan((1-sin(x))/cos(x)) = -arctan(tan(y/2)) = -(y/2 + k(pi)) = -(pi/2 - x)/2 - k(pi) = -(k + 1/4)(pi) + x/2

for the integer k between a and a+1, where a = x/(2pi) - 3/4.