Time period of a nonuniform oscillator I am given the equation of a nonuniform oscillator as
$$\dot\theta=\omega-a\sin(\theta)\tag{1}\label{eq1},$$
where $a<\omega$, and I'm told that the period, $T$, of this is given by
$$T=\frac{2\pi}{\sqrt{\omega^2-a^2}}\tag{2}\label{eq2}.$$
To work this out, I first separate the variables for $\eqref{eq1}$ to get
$$\frac{1}{\omega-a\sin(\theta)}d\theta=dt.$$
I know that for the time to increase from $0$ to $T$, then the oscillator has gone from $0$ to $2\pi$. Therefore
$$\int_0^{2\pi}\frac{1}{\omega-a\sin(\theta)}d\theta=\int_0^Tdt$$
and so
$$T=\int_0^{2\pi}\frac{1}{\omega-a\sin(\theta)}d\theta.$$
This is where the fun begins. I use the Weierstrass substitution of $u=\tan\left(\frac{\theta}{2}\right)$ to evaluate this which changes my integral to
$$T=\int_{\theta=0}^{\theta=2\pi}\frac{2}{\omega u^2+\omega-2ua}du.$$
I take the factor of $2$ outside of the integral and complete the square of the quadratic in the denominator to arrive at
$$T=2\int_{\theta=0}^{\theta=2\pi}\frac{1}{\omega\left(\left(u-\frac{a}{\omega}\right)^2+1-\frac{a^2}{\omega^2}\right)}du.$$
I factor out $\frac{1}{\omega}$ from the integral, and use the substitutions $x=u-\frac{a}{\omega}$ and $y=1-\frac{a^2}{\omega^2}$ to make this
$$T=\frac{2}{\omega}\int_{\theta=0}^{\theta=2\pi}\frac{1}{x^2+y}dx.$$
I then use the substitution $x=\sqrt{y}\tan(v)$, meaning $x^2=y\tan^2(v)$ and $dx=\sqrt{y}\sec^2(v)dv$. This makes my integral
$$T=\frac{2}{\omega}\int_{\theta=0}^{\theta=2\pi}\frac{\sqrt{y}\sec^2(v)}{y\tan^2(v)+y}dv.$$
I take out a factor of $\frac{\sqrt{y}}{y}$ and find the following:
$$T=\frac{2\sqrt{y}}{\omega y}\int_{\theta=0}^{\theta=2\pi}\frac{\sec^2(v)}{\tan^2(v)+1}dv=\frac{2\sqrt{y}}{\omega y}\int_{\theta=0}^{\theta=2\pi}\frac{\sec^2(v)}{\sec^2(v)}dv=\frac{2\sqrt{y}}{\omega y}\int_{\theta=0}^{\theta=2\pi}1 dv=\frac{2\sqrt{y}}{\omega y}\left[v\right]^{\theta=2\pi}_{\theta=0}.$$
Then I start the process of re-inserting my many substitutions. First $v=\tan^{-1}\left(\frac{x}{\sqrt{y}}\right)$, then $x=u-\frac{a}{\omega}$, then $u=\tan\left(\frac{\theta}{2}\right)$, and finally $y=1-\frac{a^2}{\omega^"}$. This gets me
$$T=\frac{2\sqrt{1-\frac{a^2}{\omega^2}}}{\omega\left(1-\frac{a^2}{\omega^2}\right)}\left[\tan^{-1}\left(\frac{\tan\left(\frac{\theta}{2}\right)-\frac{a}{\omega}}{\sqrt{1-\frac{a^2}{\omega^2}}}\right)\right]^{2\pi}_{0}.$$
I can simplify this slightly. Firstly,
$$\frac{2\sqrt{1-\frac{a^2}{\omega^2}}}{\omega\left(1-\frac{a^2}{\omega^2}\right)}=\frac{2}{\omega\sqrt{1-\frac{a^2}{\omega^2}}}=\frac{2}{\omega\sqrt{\frac{\omega^2-a^2}{\omega^2}}}=\frac{2}{\sqrt{\omega^2-a^2}},$$
and secondly
$$\tan^{-1}\left(\frac{\tan\left(\frac{\theta}{2}\right)-\frac{a}{\omega}}{\sqrt{1-\frac{a^2}{\omega^2}}}\right)=\tan^{-1}\left(\frac{\omega\tan\left(\frac{\theta}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right).$$
So now I have
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left[\tan^{-1}\left(\frac{\omega\tan\left(\frac{\theta}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)\right]^{2\pi}_{0}.$$
I feel like I'm so very close to $\eqref{eq2}$ now, but this is where I become stuck. I know that $\tan\left(\frac{2\pi}{2}\right)=\tan\left(\frac{0}{2}\right)=0$, which means when I evaluate the square brackets between $0$ and $2\pi$ they just cancel out and I'm left with
$$T=0.$$
Could someone please tell me where I have gone wrong, or what I am missing here? Been stuck on this one all day to no avail!

Taking on board the comment of @Hans Ludmark, I believe I have found the answer but I'm not entirely sure if it is rigorous. Considering the discontinuity at $\theta=\pi$ I now re-examine the equation
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left[\tan^{-1}\left(\frac{\omega\tan\left(\frac{\theta}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)\right]^{2\pi}_{0}.$$
I have split the brackets to be evaluated into two. I now write this as
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left(\left[\tan^{-1}\left(\frac{\omega\tan\left(\frac{\theta}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)\right]^{\pi}_{0}+\left[\tan^{-1}\left(\frac{\omega\tan\left(\frac{\theta}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)\right]^{2\pi}_{\pi}\right),$$
where the bracket on the left is to the left of $\theta=\pi$ and the bracket on the right is to the right of $\theta=\pi$.
I then write this as
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left(\tan^{-1}\left(\frac{\omega\tan\left(\frac{\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)^--\tan^{-1}\left(\frac{\omega\tan\left(\frac{0}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)+\tan^{-1}\left(\frac{\omega\tan\left(\frac{2\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)-\tan^{-1}\left(\frac{\omega\tan\left(\frac{\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)^+\right)$$
where a '$-$' superscript denotes the term on the left of $\pi$ and a '$+$' superscript denotes the term on the right of $\pi$. The terms $$-\tan^{-1}\left(\frac{\omega\tan\left(\frac{0}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)$$ and $$+\tan^{-1}\left(\frac{\omega\tan\left(\frac{2\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)$$ cancel since $\tan\left(\frac{0}{2}\right)=\tan\left(\frac{2\pi}{2}\right)=0$ This leaves
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left(\tan^{-1}\left(\frac{\omega\tan\left(\frac{\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)^--\tan^{-1}\left(\frac{\omega\tan\left(\frac{\pi}{2}\right)-a}{\sqrt{\omega^2-a^2}}\right)^+\right)$$
For the term on the left of $\pi$, we can take the limit to find
$$\lim\limits_{x\to\frac{\pi}{2}^-}\tan(x)=\infty,$$
and for the term on the right of $\pi$ we take the limit to find
$$\lim\limits_{x\to\frac{\pi}{2}^+}\tan(x)=-\infty.$$
This reduces our equation to
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left(\tan^{-1}(\infty)-\tan^{-1}(-\infty)\right).$$
Taking limits again we find that
$$\lim\limits_{x\to\infty}\tan^{-1}(x)=\frac{\pi}{2}$$
and
$$\lim\limits_{x\to-\infty}\tan^{-1}(x)=-\frac{\pi}{2}.$$
Hence:
$$T=\frac{2}{\sqrt{\omega^2-a^2}}\left(\frac{\pi}{2}--\frac{\pi}{2}\right)=\frac{2\pi}{\sqrt{\omega^2-a^2}}.$$
Could someone let me know if this is a sound method?
