Few days ago I came across this result: $$\int_0^{\pi/2}\frac{3\sin^2 x + 2\cos^3 x - 2}{\sin^4 x}\,\mathrm{d}x = \frac{4}{3},$$ sure, you can show this result by a few number os annoying steps which include many trig identities, since any of the three summands alone is divergent (you have to not to separate the integrated function as a sum to the whole end).
On the other hand if you plainly use the known formula $$\int_0^{\pi/2} \sin^{2n-1} x \cos^{2m-1} x \,\mathrm{d}x = \frac{1}{2}B(n,m) = \frac{\Gamma(n)\Gamma(m)}{2\Gamma(n+m)},$$
you would get $$\int_0^{\pi/2}\frac{3\sin^2 x + 2\cos^3 x - 2}{\sin^4 x}\,\mathrm{d}x = \frac{1}{2}\left(\frac{3\Gamma\left(-\frac{1}{2}\right)\Gamma\left(\frac{1}{2}\right)}{\Gamma(0)}+\frac{2\Gamma\left(-\frac{3}{2}\right)\Gamma\left(2\right)}{\Gamma\left(\frac12\right)}-\frac{2\Gamma\left(-\frac{3}{2}\right)\Gamma\left(\frac12\right)}{\Gamma(-1)}\right) = \\ \frac{1}{2}\left(\frac{\cdots}{\infty}+\frac{2\Gamma\left(-\frac{3}{2}\right)\Gamma\left(2\right)}{\Gamma\left(\frac12\right)}-\frac{\cdots}{\infty}\right)= \frac{\Gamma\left(-\frac{3}{2}\right)\Gamma\left(2\right)}{\Gamma\left(\frac12\right)} = \frac{4}{3},$$
which is a correct result.
MY QUESTION: Why this method is even correct? Is it right that the divergent parts magically cancels? Or why this method yields a correct result?
There is no problem of convergence since, close to $x=0$, the integrand is $$\frac{3}{4}+\frac{x^2}{8}+\frac{x^4}{192}+O\left(x^6\right)$$