How to find the closed form of $\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(p \cos ^{2} x+q \sin ^{2} x+r\right)^{n}}$, where $n\in N$? In my post, I found the integral
$$\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(a^{2} \cos ^{2} x+b^{2} \sin ^{2} x\right)^{2}}=\frac{\pi\left(a^{2}+b^{2}\right)}{4 a^{3} b^{3}}$$
Then  I want to find the generalized integral using similar technique by using the integral
$$
I(p, q, r)=\int_{0}^{\frac{\pi}{2}} \frac{d x}{p \cos ^{2} x+q \sin ^{2} x+r} \quad \text{ where }p+r> 0 \textrm{ and }  q+r>0.
$$
Letting $t=\tan x$ yields
$$
\begin{aligned}
I(p, q, r)&=\int_{0}^{\infty} \frac{d t}{p+qt^{2}+r\left(1+t^{2}\right)}\\
&=\int_{0}^{\infty} \frac{d t}{(q+r) t^{2}+p+r}\\&=\frac{1}{\sqrt{(p+r)(q+r)}} \left.\tan ^{-1}\left(\frac{t\sqrt{q+r} }{\sqrt{p+r}}\right)\right]_{0}^{\infty}\\
&=\frac{\pi}{2 \sqrt{(p+r)(q+r)}}
\end{aligned}
$$
Differentiating it w.r.t. $r$ by $n$ times yields
$$
\begin{aligned}\int_{0}^{\frac{\pi}{2}} \frac{(-1)^{n}n! d x}{\left(p \cos ^{2} x+q \sin ^{2} x+r\right)^{n+1}}=\frac{\pi}{2 }\cdot \frac{\partial^{n}}{\partial r^{n}}\left(\frac{1}{\sqrt{(p+r)(q+r)}}\right) \\
\boxed{\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(p \cos ^{2} x+q\sin ^{2} x+r\right)^{n+1}}=\frac{(-1)^{n} \pi}{2n !} \frac{\partial^{n}}{\partial r^{n}}\left(\frac{1}{\sqrt{(p+r)(q+r)}}\right)}
\end{aligned}
$$
Using the formula, we can evaluate
$$
\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(p \cos ^{2} x+q \sin ^{2} x+r\right)^{2}}=\frac{-\pi}{2} \frac{\partial}{\partial r}\left(\frac{1}{\sqrt{(p+r)(q+r)}}\right)= \frac{\pi(p+q+2r)}{4\left[(p+r)( q+r)\right]^{\frac{3}{2}}}
$$
For higher derivative, applying Leibniz’s Rule gives
$$
\begin{aligned}\frac{d^{n}}{d r^{n}}\left[(p+r)^{-\frac{1}{2}}(q+r)^{-\frac{1}{2}}\right]&= (-1)^n \sum_{k=0}^{n}\left(\begin{array}{l}
n \\
k
\end{array}\right)\left(\frac{1}{2} \right)_k(p+r)^{-\frac{1}{2}-k}\left(\frac{1}{2} \right)_{n-k}(q+r)^{-\frac{1}{2}-n+k} \\&=\frac{(-1)^n}{(q+r)^{n} \sqrt{(p+r)(q+r)}} \sum_{k=0}^{n} \binom{n}{k} \left(\frac{1}{2}\right)_{k}\left(\frac{1}{2}\right)_{n-k}\left(\frac{q+r}{p+r}\right)^{k}\end{aligned}
$$
where $\displaystyle (\alpha)_n=\frac{\Gamma(\alpha+n)}{\Gamma(n)} $.
Now we can conclude that for any natural number $n\geq 2$,
$$
\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(p\cos ^{2} x+q\sin ^{2} x+r\right)^{n+1}}\\=\boxed{\frac{\pi}{2n!(q+r)^{n} \sqrt{(p+r)(q+r)}} \sum_{k=0}^{n} \binom{n}{k}\left(\frac{1}{2}\right)_{k}\left(\frac{1}{2}\right)_{n-k}\left(\frac{q+r}{p+r}\right)^{k}}
$$
Question:
Is there any other solution?

Let $a=p+r$, $b=q+r$ and, for sure, as you did $x=\tan^{-1}(t)$
$$I_n=\int_{0}^{\frac{\pi}{2}} \frac{d x}{\left(p \cos ^{2} (x)+q \sin ^{2} (x)+r\right)^{n}}=\int_0^\infty \frac{(1+ t^2)^{n-1} }{(a+b\,t^2)^n }\,dt$$There is an antiderivative
$$\int\frac{(1+ t^2)^{n-1} }{(a+b\,t^2)^n }\,dt=\frac t {a^{n}}\, F_1\left(\frac{1}{2};1-n,n;\frac{3}{2};-t^2,-\frac{b }{a}t^2\right)$$ where appears  the Appell hypergeometric function of two variables.
Using the bounds and simplifying, this gives
$$I_n=(-1)^n  \frac{\pi ^{3/2}}{2 a^n}\Bigg[\frac{\, _2F_1\left(\frac{1}{2},n;n+\frac{1}{2};\frac{b}{a}\right)}{\Gamma (1-n)
   \Gamma \left(n+\frac{1}{2}\right)}-\left(\frac{a}{b}\right)^{n-\frac{1}{2}}\frac{\, _2F_1\left(\frac{1}{2},1-n;\frac{3}{2}-n;\frac{b}{a}\right)}{\Gamma
   \left(\frac{3}{2}-n\right) \Gamma (n)} \Bigg]$$ where appear two Gaussian    hypergeometric functions.
Edit
Let $b=k\,a$ to get
$$I_n=\frac{\pi}{a^n \,k^{n-\frac{1}{2}} }\,\frac {P_n(k)}{c_k}$$  The $c_k$'s form sequence $A101926$ in $OEIS$ and the first polynomials are
$$\left(
\begin{array}{cc}
n & P_n(k) \\
 1 & 1 \\
 2 & k+1 \\
 3 & 3 k^2+2 k+3 \\
 4 & 5 k^3+3 k^2+3 k+5 \\
 5 & 35 k^4+20 k^3+18 k^2+20 k+35 \\
 6 & 63 k^5+35 k^4+30 k^3+30 k^2+35 k+63 \\
 7 & 231 k^6+126 k^5+105 k^4+100 k^3+105 k^2+126 k+231 \\
 8 & 429 k^7+231 k^6+189 k^5+175 k^4+175 k^3+189 k^2+231 k+429 
\end{array}
\right)$$ which are interesting (it would be worth to analyse the patterns using $OEIS$).
