<s>[INST] How to calculate the improper integral $\int_0^\infty\left(\frac{1}{\sqrt{x^2+4}}-\frac{P}{x+2}\right)dx$ This is the first time I've seen a problem like this. I have no idea what to do. Detailed guidance would be of great help.
For which values of P does the integral converge?
$$\int_0^\infty\left(\dfrac{1}{\sqrt{x^2+4}}-\dfrac{P}{x+2}\right)dx$$
Thank You!
 [/INST] Let our function be $f(x)$. The function $f(x)$ behaves nicely in the interval $[0,1]$, so it is enough to find $p$ such that $\int_1^\infty f(x)\,dx$ converges.  
If $p\le 0$, then Comparison shows divergence. So we can assume $p\gt 0$.
Rewrite $f(x)$ as $\frac{x+2-p\sqrt{x^2+4}}{(x+2)\sqrt{x^2+4}}$, and then rationalize the numerator by multiplying top and bottom by $x+2+p\sqrt{x^2+4}$. We get
$$f(x)=\frac{x^2(1-p^2) +4x+4(1-p^2)}{(x+2)\sqrt{x^2+4}\left(x+2+\sqrt{x^2+4}\right)}.$$
If $p=1$, then $f(x)\le \frac{4x}{2x^3}=\frac{2}{x^2}$. Since $\int_1^\infty \frac{2}{x^2}\,dx$ converges, so does $\int_1^\infty f(x)\,dx$. 
If $0\lt p\lt 1$ or $p\gt 1$, then our integral diverges. There are two cases to consider. 
Suppose that $0\lt p\lt 1$. Let $g(x)=\frac{1}{x}$. One can show that
$$\lim_{x\to\infty} \frac{f(x)}{g(x)}=\frac{1-p^2}{2}.$$
 Since $\int_1^\infty g(x)\,dx$ diverges, so does $\int_1^\infty f(x)\,dx$. The argument for $p\gt 1$ is similar.  
</s>