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

I would like to calculate the uncertainty of the nth Eigenstate of a 1-dim harmonic oscillator. To obtain the result I have to solve the integral

$$\int_{-\infty}^{\infty} \psi^* x^2 \psi \:dx$$ with $$\psi(n,x)=\frac{e^{-\frac{x^2}{2}} H_n(x)}{\pi^{\frac{1}{4}}\sqrt{2^n n!}}$$, where $H_n(x)$ is the Hermite polynomial (degree n) in the physicist version (as implemented in Mathematica). In Mathematica this equals to the Integral over

(2^-n E^-x^2 x^2 HermiteH[n, x]^2)/(Sqrt[π] n!)

Doing this manually gives $1/2+n$, but i can't get Mathematica to solve this integral without specifying $n$. I used `

Assuptions=n ∈ Integers && n >= 0

Is there anyway to solve similar integrals with Mathematica?

Edit: Thanks for you answer, but I should have mentioned, that I'm looking for a way to let Mathematica solve such problems analytical.

share|improve this question
Closely related or a duplicate How do I evaluate a symbolic integral involving Hermite polynomials?. – Artes Dec 25 '13 at 20:00
You could code up (50) or (51) from here. – b.gatessucks Dec 26 '13 at 9:36
up vote 5 down vote accepted

An easy way without struggling with the integral:

 Table[Integrate[(2^-n E^-x^2 x^2 HermiteH[n, x]^2)/(Sqrt[π] n!), {x, -Infinity, Infinity}],
       {n, 1, 5}], n]
 1/2 (1 + 2 n)
share|improve this answer
Is there any way to let Mathematica solve this problem analytical? – Gebbo Dec 25 '13 at 23:17
@Gebbo Not AFAIK – Dr. belisarius Dec 26 '13 at 2:24

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.