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?


  • $\begingroup$ Thanks! At least one passage is then correct. Interesting thread, that one, btw. $\endgroup$ – geodude Feb 28 '14 at 22:00
  • $\begingroup$ Does anyone know how to calculate the following integral? - No. Not anyone knows how to calculate this integral. :-) $\endgroup$ – Lucian Feb 28 '14 at 22:03
  • $\begingroup$ Or does "not anyone" mean "nobody"? Quantifiers in English are cumbersome... $\endgroup$ – geodude Feb 28 '14 at 22:08

Following the analysis here:

$$\begin{align} F(x) &= \int_0^{\infty} \frac{dy}{y} e^{-y-\frac{x}{y}}\end{align}$$

Sub $u=y+\frac{x}{y}$, then

$$y = \frac12 \left (u \pm \sqrt{u^2-4 x}\right )$$ $$dy = \frac12 \left ( 1 \pm \frac{u}{\sqrt{u^2-4 x}} \right ) du$$


$$\begin{align}F(x) &= \frac1{4 x} \int_{\infty}^{2 \sqrt{x}} du \left ( 1 - \frac{u}{\sqrt{u^2-4 x}} \right )\left (u + \sqrt{u^2-4 x}\right ) e^{-u} \\ &+ \frac1{4 x} \int_{2 \sqrt{x}}^{\infty} du \left ( 1 + \frac{u}{\sqrt{u^2-4 x}} \right )\left (u - \sqrt{u^2-4 x}\right )e^{-u}\\ &= 2 \int_{2 \sqrt{x}}^{\infty} du \frac{e^{-u}}{\sqrt{u^2-4 x}}\\ &= 2 \int_0^{\infty} dv \, e^{-2 \sqrt{x} \cosh{v}}\\ &= 2 K_0(2 \sqrt{x})\end{align}$$

By using recurrence relations for the $K_n$, we see that the above simple expression is equivalent to the one derived using differentiation under the integral sign.

| cite | improve this answer | |

What you have described is differentiation under the integral sign and the only assumption (I believe) is that $g$ and $\frac{\partial g}{\partial x}$ are continuous.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.