Consider the function (coming from a joint probability density): $$ f(x,y) = \frac{1}{y}e^{-y-\frac{x}{y}}. $$
I want to evaluate the definite integral (marginal): $$ F(x) = \int_0^\infty f(x,y)\,dy. $$
It is very hard to find a primitive in $y$, so what I did was the following workaround: $$ \int f(x,y)\,dx = -e^{-y-\frac{x}{y}}. $$
So if we let $g(x,y):= -e^{-y-\frac{x}{y}}$, we can write: $$ f(x,y) = \frac{\partial g}{\partial x}(x,y). $$
Therefore: $$ F(x) = \int_0^\infty \frac{\partial g}{\partial x}(x,y)\,dy. $$
Now the trick was: can we move the derivation out of the integral? Under what assumptions? If that were the case, we could write: $$ F(x) = \frac{d}{dx} \int_0^\infty g(x,y)\,dy, $$
which can be calculated in terms of Bessel functions:
$$ F(x) = \frac{d}{dx} \int_0^\infty -e^{-y-\frac{x}{y}}\,dy = -\frac{d}{dx} \big(2\sqrt{x}\,K_1(2\sqrt{x})\big). $$
Deriving: $$ F(x) = K_0(2\sqrt{x}) - \frac{1}{\sqrt{x}}\,K_1(2\sqrt{x})+K_2(2\sqrt{x}). $$
(The last two passages according to Wolfram Alpha, for $x\ge 0$.) The $K_n$ should be the "modified Bessel functions of the 2nd kind".
I would like to ask:
- Is it "legal" to carry the derivative out of the integral sign?
- Are the last two (Wolfram Alpha) passages correct?
- Is there any other way of obtaining $F(x)$? What is the result?
Thanks.