Message Boards Message Boards

1
|
13474 Views
|
11 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Definite integral of gaussian times sqare root of x gives wrong result

Definite integrals of the type gaussian distribution times sqare root of x from 0 to inf give imaginary results whereas the functions are real valued in this interval.

int [sqrt(x)*exp(-(x-1)**2),x,0,inf] ? -0.07..i

int [x**(-1/2)*exp(-(x-1)**2),x,0,inf] ? 0.4..i

By the way I would love to know the correct symbolic integral but not only does wolfram alpha struggle but maxima and me as well.

Edit: I was not specific in that I would like to know the symbolic integral.

POSTED BY: Wolfgang Brehm
11 Replies

OK thank you all - the conclusion is: The bug is known and fixed, just not in the version we were using.

For future reference the solution is:

int [ exp(-(x-m)**2/s)/sqrt(x) , {x,0,inf}] 
= pi/2 * ( BesselI(1/4,m**2/(2*s))+BesselI(-1/4,m**2/(2*s)) )  * sqrt(m) * exp( - m**2/(2*s))
POSTED BY: Wolfgang Brehm
Posted 9 years ago

I had no such expectations. I was just hopeful/naïve that requesting the indefinite integral might provide more information. (And it did ... in a way.)

POSTED BY: Jim Baldwin

Oh, I see now. The incorrect result in Wolfram|Alpha is computed (by Integrate) in Mathematica version 9, while the correct approximate answers seem to use NIntegrate. The issue has been resolved in later versions of Mathematica, and hopefully Alpha will catch up soon.

POSTED BY: Ilian Gachevski
Posted 9 years ago

But I don't think it's completely fixed in Mathematica 10.0.2 (Windows):

In[33]:= \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(\[Infinity]\)]\(
\*FractionBox[\(1\), \(
\*SqrtBox[\(x\)] Exp[\((x - 1)\)^2]\)] \[DifferentialD]x\)\)

Out[33]= (I BesselK[1/4, 1/2])/Sqrt[2 E]

This does not give a real result.

POSTED BY: Jim Baldwin

Some day...

In[1]:= i1 = Integrate[1/(Sqrt[x]*Exp[(x - 1)^2]), {x, 0, Infinity}]
N[i1]

Out[1]= (\[Pi] (BesselI[-(1/4), 1/2] + BesselI[1/4, 1/2]))/(2 Sqrt[E])

Out[2]= 1.97373215009

So it seems to be repaired in what will become the next released version.

POSTED BY: Daniel Lichtblau

The second example has also been fixed in the current development version and release candidates.

In[1]:= int2 = Integrate[(1/Sqrt[x]) Exp[-(x - 1)^2], {x, 0, Infinity}]

Out[1]= (\[Pi] (BesselI[-(1/4), 1/2] + BesselI[1/4, 1/2]))/(2 Sqrt[E])

In[2]:= N[int2, 50]

Out[2]= 1.9737321500898237789841487512373971273398502283395
POSTED BY: Ilian Gachevski

Why would you expect the indefinite integral to have a closed form?

In[1]:= int = Integrate[Sqrt[x] Exp[-(x - 1)^2], {x, 0, Infinity}]

Out[1]= (Gamma[3/4] Hypergeometric1F1[3/4, 1/2, 1] + 2 Gamma[5/4] Hypergeometric1F1[5/4, 3/2, 1])/(2 E)

In[2]:= N[int, 50]

Out[2]= 1.6436165407874952730553651165549411806023882736885
POSTED BY: Ilian Gachevski

I get the same thing - the numerical integration is fine, but the symbolic integration seems to be broken.

POSTED BY: Wolfgang Brehm
Posted 9 years ago

It is curious. If I enter the indefinite integral into Wolfram Alpha

Integrate[Sqrt[x] Exp[-(x - 1)^2]]

I get the following output:

Integral

I am hoping for an enlightening answer from Daniel Lichtblau.

POSTED BY: Jim Baldwin

Thanks for your reply,

I know that you can compute the numeric integral which is real and positive. But this is sadly not satisfactory:

  1. It highlights even more that there is an error
  2. I wold like to know the symbolic integral
POSTED BY: Wolfgang Brehm
Posted 9 years ago

I don't know the syntax for Wolfram Alpha but in Mathematica:

In[1]:= NIntegrate[Sqrt[x] Exp[-(x - 1)^2], {x, 0, Infinity}]
NIntegrate[x^(-1/2)*Exp[-(x - 1)^2], {x, 0, Infinity}]

Out[1]= 1.64362

Out[2]= 1.97373

Added comment: I just now entered your equation into Wolfram Alpha and it does recognize your formula as you intended. Sorry, don't know what to say.

POSTED BY: Jim Baldwin
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract