Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to solve this integral:

$$ \left(\int_{-\infty}^{\infty}\frac{1}{\sqrt{2\pi}\sigma}e^\frac{-x^2}{2\sigma^2}\left(\int_{x}^{\infty}\frac{1}{\sqrt{2\pi}\sigma}e^\frac{-(y-\mu)^2}{2\sigma^2}dy\right)^ndx\right)^k $$ and that is what i found in one of post:

 Exp[-((y - \[Mu])^2/(2*\[Sigma]^2))]), 
 {x, -Infinity, Infinity}, {y, x, Infinity}]^k

dont know where to put the 'n' power ?

share|improve this question
Nested NIntegrate? NIntegrate[... NIntegrate[...]^n, ...]. And actually the inner one is an erf function, which can be analyticlly integrated. –  Yi Wang Feb 11 '14 at 10:40
And besides, it is recommended to first make it dimensionless. Then you might be able to make it quasi-analytically. –  Alexei Boulbitch Feb 11 '14 at 11:15
suppose to be power of (n-k) instead of 'n'$$ \text{NIntegrate}\left[\frac{\exp \left(-\frac{x^2}{2 \sigma ^2}\right) \text{NIntegrate}\left[\frac{\exp \left(-\frac{(y-\mu )^2}{2 \sigma ^2}\right)}{\sqrt{2 \pi } \sigma },\{y,x,\infty \}\right]^{n-k}}{\sqrt{2 \pi } \sigma },\{x,-\infty ,\infty \}\right]^k $$ –  user9882 Feb 11 '14 at 11:16
@AlexeiBoulbitch Can you elaborate on your comment a bit? I would be interested what you mean with quasi analtytical. Also, how do you know it's not dimensionless? –  sebhofer Feb 11 '14 at 22:49

2 Answers 2

up vote 1 down vote accepted

Lets consider some parameters:

\[Sigma] = 1; \[Mu] = 1; n = 10; k = 4;

I think n should be greater than k for your case.

   Exp[-((y - \[Mu])^2/(2*\[Sigma]^2))]), {y, x, Infinity}]^(n - 
  k), {x, -Infinity, Infinity}]^k

It gives

share|improve this answer
yes this code works , it is the same as in my comment. thanks –  user9882 Feb 12 '14 at 9:11

To respond to the comment-question of sebhofer:

The internal integral is calculated analytically to the end:

 Integrate[Exp[-(y - \[Mu])^2/(2*\[Sigma]^2)], {y, x, \[Infinity]}, 
 Assumptions -> {\[Sigma] > 0, \[Mu] > 0}]

(* Sqrt[\[Pi]/2] \[Sigma] Erfc[(x - \[Mu])/(Sqrt[2] \[Sigma])] *)

Introducing the new variables: x=sigma*ksi and mu=sigma*m one transforms the main expression into the following:

\int_{-\infty }^{\infty } e^{\frac{\xi ^2}{2}} \text{erfc}\left(\frac{\xi -m}{\sqrt{2}}\right)^n \, d\xi

This integral seems not to converge. So the problem is solved. I guess, however, that the sign in front of x^2/2sigma^2 in the original integral should be minus. In the latter case one can try to do something with this integral. The original question does not specify, if n is any, or only integer, only positive, only negative or both. Assuming that it is integer, and assuming for a moment that m=0, one finds exact values of the integral:

      Exp[-\[Xi]^2/2] Erfc[\[Xi]/Sqrt[2]]^
       n, {\[Xi], -\[Infinity], \[Infinity]}], {n, 0, 5}]

   (*  {Sqrt[2 \[Pi]], Sqrt[2 \[Pi]], (4 Sqrt[2 \[Pi]])/3, 2 Sqrt[2 \[Pi]], (
     16 Sqrt[2 \[Pi]])/5, (16 Sqrt[2 \[Pi]])/3}  *)

It fails, however, to return an analytic solution in the simpliest case n=1, and a non-zero m. In this case one might find it useful to make a quasi-analytic solution. That is, one finds a numeric solution in a number of points of a certain interval of interest, say, for m between 0 and 1, and then approximates the result by a reasonable analytical function as follows:

This makes a table of the integral values with n=1:

lst = Table[{m, 
     Exp[-\[Xi]^2/2] Erfc[(\[Xi] - m)/Sqrt[
       2]], {\[Xi], -\[Infinity], \[Infinity]}]}, {m, 0, 1, 0.1}];

This fits it to a polynomial:

ft = Fit[lst, {1, m, m^2}, m]
(*  2.50308 + 1.47271 m - 0.161187 m^2  *)

And this provides a visual control of the fitting quality:

  Plot[ft, {m, 0, 1}, PlotStyle -> Red]

That's what should be obtained:enter image description here It is clear that the obtained polynomial represents an approximation for the integral accurate in the indicated interval of m. It can, therefore, be used for further analytical calculations. Further, the same type of approximations one can find for any n. In principle, with luck one can then try to approximate also the dependence of the integral upon n. My experience tells, however, that approximation over two parameters is typically not too accurate. It depends upon the problem being solved, personal luck and on how desperate one needs to get the analytic expression.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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