<s>[INST] Integration by Substitution with $~ t=\tan^{}\left( \frac{ \theta_{} }{ 2 } \right) ~$ The angle was halved I've been encountering the problem of the below integration.
$$  \int_{0 }^{2\pi  } \frac{  d\theta   }{  R+ r \cdot \cos^{}\left(\theta_{} \right)   }  \tag{1}   $$
The official description states that the above integration formula can be calculated using substitution of integration.
$$  t=\tan^{}\left( \frac{  \theta_{}   }{  2  }  \right)  $$
$$ \therefore ~~  \int_{0 }^{2\pi  } \frac{  d\theta   }{  R+ r \cdot \cos^{}\left(\theta_{} \right)   } = \frac{  2\pi   }{  \sqrt{ R ^{2} -r ^{2}  }   }    $$
Currently I can't derive the above RHS.
I think firstly find out the form of result of calculations of indefinite integral of eqn1 is wiser way.
What I tried so far are as below.
$$  t= \tan^{}\left( \frac{  \theta_{}   }{  2  }  \right)  $$
$$  \frac{  \theta_{}   }{  2  }= \tan^{-1} \left( t \right) ~~ \leftarrow~~ \text{Thought that this approach won't work}  $$
$$  \frac{  dt  }{  d\theta   } = \sec^{2}\left( \frac{  \theta_{}   }{  2  }  \right) \cdot \frac{1}{2}  $$
$$  \frac{  2dt  }{  d\theta   } = \sec^{2}\left( \frac{  \theta_{}   }{  2  }  \right)   $$
$$  \frac{  d\theta   }{  2 dt  } =\sec^{-2}\left( \frac{  \theta_{}   }{  2  }   \right)  $$
$$  \frac{  d\theta   }{  2 dt  } = \left( \sec^{}\left( \frac{  \theta_{}   }{  2  }  \right)    \right)^{-2}  $$
$$  \frac{  d\theta   }{  2 dt  } = \left( \cos^{-1}\left( \frac{  \theta_{}   }{  2  }  \right)    \right)^{-2}  $$
$$  \frac{  d\theta   }{  2 dt  } =  \cos^{2}\left( \frac{  \theta_{}   }{  2  }  \right)     $$
$$  d\theta = 2 dt \cdot \cos^{2}\left(\frac{  \theta_{}   }{  2  } \right)  $$
First things to first, the equation1 has $~ \cos^{}\left(\theta_{} \right)  ~$ however how can I handle $~  t=\tan^{}\left( \frac{  \theta_{}   }{  2  }  \right)   ~$ ??
 [/INST] Note that:
$$\cos(\theta)=\cos(2\frac{\theta}2)=\cos^2(\frac{\theta}2)-\sin^2(\frac{\theta}2)=\frac{\cos^2(\frac{\theta}2)-\sin^2(\frac{\theta}2)}{\cos^2(\frac{\theta}2)+\sin^2(\frac{\theta}2)}$$
Simplify by $\displaystyle{\cos^2(\frac{\theta}2)}$:
$$\cos(\theta)=\displaystyle{\frac{1-\tan^2(\frac{\theta}2)}{1+\tan^2(\frac{\theta}2)}}$$.
With the above, the integrand becomes:
$$\displaystyle{\frac{1}{R+r\cdot\frac{1-\tan^2(\frac{\theta}2)}{1+\tan^2(\frac{\theta}2)}}=\frac{1+\tan^2(\frac{\theta}2)}{R(1+\tan^2(\frac{\theta}2))+r(1-\tan^2(\frac{\theta}2))}}$$
Substitute $t=\tan(\frac{\theta}2)$. It follows that $dt=\frac12(1+\tan^2(\frac{\theta}2))d\theta$ and the integral becomes:
$$2\cdot2\int_0^\infty\frac{1}{R(1+t^2)+r(1-t^2)}dt$$ which you should be able to easily solve.
</s>