Message Boards Message Boards


Integration in reals of orbitals not working as expected: ensuring reals ?

Posted 10 years ago
3 Replies
2 Total Likes

I am trying to make my way on the Mathematica learning curve and am testing some integrals that I know how to solve.

This is a case of an integral over two orbital-like functions (never mind if you are not familiar with them). My function is:
Simplify[(x - x1) (y - y2) Exp[-alpha ((x - x1)^2 + (y - y1)^2 + (z - z1)^2)] Exp[-alpha ((x - x2)^2 + (y - y2)^2 + (z - z2)^2)]]

x, y and z are real variables, so I put:
Element[{x, y, z}, Reals]
x1,x2,y1,y2,z1,z2 are constants and real, so:
Element[{x1, y1, z1, x2, y2, z2}, {Constants, Reals}]
alpha is also a constant:
Element[{alpha}, {Constants, Reals, Positive}]
(I am not sure about the statement Positive)

I then integrate by:
Integrate[(x - x1) (y - y2) Exp[- alpha ((x - x1)^2 + (y - y1)^2 + (z - z1)^2)] Exp[-alpha ((x - x2)^2 + (y - y2)^2 + (z - z2)^2)], {x, -Infinity, +Infinity}, {y, -Infinity, +Infinity}, {z, -Infinity, +Infinity}, Assumptions -> alpha > 0]

and basically my problem is that it takes so long to evaluate this. The end answer is correct but I am just wondering if I did something pretty stupid. Would it have been better to put the assumptions inside the Integrate block or something alike ?


POSTED BY: Patrick Bultinck
3 Replies
Posted 10 years ago
Ah, so the extremely long calculation times were "a glitch" and we may never track down and diagnose and correct the cause of that.

I sympathize with your reluctance to reboot Mathematica because of long calculation times needed to restore large prior results. In the past some people have suggested various ways of saving notebooks to include both "this is how to recalculate these results" and "this is how to just do literal assignment of these previously calculated results." I've never found a style of doing that which was particularly convenient for me, some methods use "manual copy result and paste into assignment" that might work for you. Perhaps someone can suggest a method or point to a prior example that would work for you.
POSTED BY: Bill Simpson
Posted 10 years ago
I don't know how fast your computer is or how much memory it has and I don't know exactly how you are using assumptions, but with a modest several year old computer  I get
 In[1]:= qq = 2(* evaluate anything to get the kernel hauled into memory *)
 Out[1]= 2
 In[2]:= Timing[Integrate[(x - x1) (y - y2) Exp[-alpha ((x - x1)^2 + (y - y1)^2 + (z - z1)^2)] Exp[-alpha ((x - x2)^2 + (y - y2)^2 + (z - z2)^2)], {x, -Infinity, +Infinity}, {y, -Infinity, +Infinity}, {z, -Infinity, +Infinity}, Assumptions -> alpha > 0]]
 Out[2]= {28.8289, (Pi^(3/2)*(-x1 + x2)*(y1 - y2))/(8*Sqrt[2]*alpha^(3/2)*E^((alpha*((x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2))/2))}
 In[1]:= qq = 2 (* now kill the kernel to get a fair comparison and try it again *)
 Out[1]= 2

In[2]:= $Assumptions = Element[{x, y, z, x1, y1, z1, x2, y2, z2, alpha}, Reals] && alpha > 0;
Timing[Integrate[(x - x1) (y - y2) Exp[-alpha ((x - x1)^2 + (y - y1)^2 + (z - z1)^2)] Exp[-alpha ((x - x2)^2 + (y - y2)^2 + (z - z2)^2)], {x, -Infinity, +Infinity}, {y, -Infinity, +Infinity}, {z, -Infinity, +Infinity}]]

Out[2]= {29.4373, (Pi^(3/2)*(-x1 + x2)*(y1 - y2))/(8*Sqrt[2]*alpha^(3/2)*E^((alpha*((x1 - x2)^2 + (y1 - y2)^2 + (z1 - z2)^2))/2))}

So in about 30 seconds I get a result.

I don't believe that Constants and Positive work within Element and it doesn't appear that any of the assumptions, other than alpha>0, make any significant difference in the timing or the result.
POSTED BY: Bill Simpson
Thank you. I rebooted my machine and I now get the 17-30 second turnaround you mention. The timing depends (obviously) on the degree of the polynomials I put in front.

I was kind of hesitant to reboot as it seems that closing Mathematica and then opening the notebook again "forgets" the data that I pasted from excel and since they are 18x18 matrices (heaps of them), I kind of did not fancy doing this over again.
POSTED BY: Patrick Bultinck
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract