1
$\begingroup$

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:

NIntegrate[((1/(Sqrt[2*Pi]*σ))*Exp[-(x^2/(2*σ^2))])*
   ((1/(Sqrt[2*Pi]*σ))*
 Exp[-((y - μ)^2/(2*σ^2))]), 
 {x, -Infinity, Infinity}, {y, x, Infinity}]^k

dont know where to put the 'n' power ?

$\endgroup$
4
  • 3
    $\begingroup$ Nested NIntegrate? NIntegrate[... NIntegrate[...]^n, ...]. And actually the inner one is an erf function, which can be analyticlly integrated. $\endgroup$
    – Yi Wang
    Commented Feb 11, 2014 at 10:40
  • $\begingroup$ And besides, it is recommended to first make it dimensionless. Then you might be able to make it quasi-analytically. $\endgroup$ Commented Feb 11, 2014 at 11:15
  • $\begingroup$ 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 $$ $\endgroup$
    – UdiW
    Commented Feb 11, 2014 at 11:16
  • $\begingroup$ @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? $\endgroup$
    – sebhofer
    Commented Feb 11, 2014 at 22:49

2 Answers 2

1
$\begingroup$

Lets consider some parameters:

σ = 1; μ = 1; n = 10; k = 4;

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

  NIntegrate[((1/(Sqrt[2*π]*σ))*Exp[-(x^2/(2*σ^2))])*
  NIntegrate[((1/(Sqrt[2*π]*σ))*
   Exp[-((y - μ)^2/(2*σ^2))]), {y, x, Infinity}]^(n - 
  k), {x, -Infinity, Infinity}]^k

It gives

0.029438
$\endgroup$
1
  • $\begingroup$ yes this code works , it is the same as in my comment. thanks $\endgroup$
    – UdiW
    Commented Feb 12, 2014 at 9:11
1
$\begingroup$

To respond to the comment-question of sebhofer:

The internal integral is calculated analytically to the end:

 Integrate[Exp[-(y - μ)^2/(2*σ^2)], {y, x, ∞}, 
 Assumptions -> {σ > 0, μ > 0}]

(* Sqrt[π/2] σ Erfc[(x - μ)/(Sqrt[2] σ)] *)

Introducing the new variables: x=sigmaksi and mu=sigmam 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:

    Table[Integrate[
      Exp[-ξ^2/2] Erfc[ξ/Sqrt[2]]^n, {ξ, -∞, ∞}], {n, 0, 5}]

   (*  {Sqrt[2 π], Sqrt[2 π], (4 Sqrt[2 π])/3, 2 Sqrt[2 π], (
     16 Sqrt[2 π])/5, (16 Sqrt[2 π])/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, 
    NIntegrate[
     Exp[-ξ^2/2] Erfc[(ξ - m)/Sqrt[
       2]], {ξ, -∞, ∞}]}, {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:

 Show[{
  ListPlot[lst],
  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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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