Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Trying to evaluate an integral. To be specific, I'm trying to find the expectation value of $x^2$ for the ground state of hydrogen. Here is the code I used:

  Integrate[x^2/(Pi*a^3) E^((-2 Sqrt[x^2 + y^2 + z^2])/a), {x,-Infinity, Infinity}]]

The odd part is it worked when I calculated $\left<x\right>$, i.e. just drop an $x$ from the first fraction.

share|improve this question
Did you try letting Mathematica know that $a$ is real, say with Assuming[] ? – Zet Jun 7 '14 at 15:21
Just did, no such luck:( – Sam Jun 7 '14 at 15:26
Then I'd try to convert the integral into spherical coordinates (although it is disappointing that M didn't try it). – Zet Jun 7 '14 at 15:44
Try a change of coordinate cartesian-spherical. – b.gatessucks Jun 7 '14 at 15:44
Yes, that turned out to be the proper way to do the problem anyway. – Sam Jun 7 '14 at 16:35

Your Answer


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

Browse other questions tagged or ask your own question.