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!
 A: Note that
$$
T=
\int_0^{2\pi}\frac{2e^{-i\theta}}{2i\omega-a(e^{i\theta}-e^{-i\theta}) }ie^{i\theta}\,d\theta=
\int_0^{2\pi}\frac{2}{2i\omega e^{i\theta}-a(e^{2i\theta}-1) }ie^{i\theta}\,d\theta=\int_\gamma f,
$$
with $\gamma\colon[0,2\pi]\to\mathbb C$ given by $\gamma(\theta)=e^{i\theta}$ and $f(z)=2/(-az^2+2i\omega z+a)$. By the Residues' theorem:
$$
T=2\pi i \,{\rm Res}\left(f,\frac{i(\omega+\sqrt{\omega^2-a^2})}{a}\right)=2\pi i\frac{2}{-a}\cdot\frac1{-\frac{2i\sqrt{\omega^2-a^2}}{a}}= \frac{2\pi}{{\sqrt{\omega^2-a^2}}}
$$
since the poles satisfy $|i(\omega+\sqrt{\omega^2-a^2})/a|<1$ and $|i(\omega-\sqrt{\omega^2-a^2})/a|>1$.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\on}[1]{\operatorname{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
T & = \bbox[5px,#ffd]{\left.\int_{0}^{2\pi}{\dd\theta \over
\omega - a\sin\pars{\theta}}
\,\right\vert_{\, \omega\ >\ a\ \geq\ 0}} =
\int_{-\pi}^{\pi}{\dd\theta \over
\omega + a\sin\pars{\theta}}
\\[5mm] & =
\int_{0}^{\pi}\bracks{{1 \over \omega + a\sin\pars{\theta}} +
{1 \over \omega - a\sin\pars{\theta}}}\dd\theta
\\[5mm] & =
2\omega\int_{0}^{\pi}{\dd\theta \over
\omega^{2} - a^{2}\sin^{2}\pars{\theta}} =
2\omega\int_{-\pi/2}^{\pi/2}{\dd\theta \over
\omega^{2} - a^{2}\cos^{2}\pars{\theta}}
\\[5mm] & =
4\omega\int_{0}^{\pi/2}{\dd\theta \over
\omega^{2} - a^{2}\cos^{2}\pars{\theta}} =
4\omega\int_{0}^{\pi/2}{\sec^{2}\pars{\theta} \over
\omega^{2}\sec^{2}\pars{\theta} - a^{2}}\,\dd\theta
\\[5mm] & =
4\omega\int_{0}^{\pi/2}{\sec^{2}\pars{\theta} \over
\omega^{2}\tan^{2}\pars{\theta} + \omega^{2} -a^{2}}\,\dd\theta
\\[5mm] & =
4\omega\,{1 \over \omega^{2} - a^{2}}\,{\root{\omega^{2} - a^{2}} \over \verts{\omega}}
\ \times
\\[2mm] & \int_{0}^{\pi/2}{\verts{\omega}\sec^{2}\pars{\theta}/\root{\omega^{2} - a^{2}} \over
\bracks{\verts{\omega}\tan\pars{\theta}/\root{\omega^{2} - a^{2}}}^{2} + 1}\,\dd\theta
\end{align}

Sets $\ds{t = \verts{\omega}\tan\pars{\theta}/\root{\omega^{2} - a^{2}}}$:
\begin{align}
T & = \bbox[5px,#ffd]{\left.\int_{0}^{2\pi}{\dd\theta \over
\omega - a\sin\pars{\theta}}
\,\right\vert_{\, \omega\ >\ a\ \geq\ 0}} =
{4\on{sgn}\pars{\omega} \over \root{\omega^{2} - a^{2}}}\
\underbrace{\int_{0}^{\infty}{\dd t \over t^{2} + 1}}
_{\ds{\pi/2}}
\\ & =
\bbx{2\pi \over \root{\omega^{2} - a^{2}}} \\ &
\end{align}
A: 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?
