Expectation values of polynomials of \(x\) or \(p\) can be
computed using the ladder operators, without knowing the wave
functions explicitly, and without doing any integrals.
We can now compute the expectation value of physical observables
\(A(x,p)\) in any Hamiltonian eigenfunction. First, we express of
position and momentum in terms of the ladder operators,
\begin{align}
\hat x & = \sqrt{\frac{\hbar}{2m\omega}}(\hat{a}+\hat{a}^\dagger)\,, \\[1ex]
\hat p & = -i \sqrt{\frac{\hbar m \omega}{2}}(\hat{a}-\hat{a}^\dagger) \, .
\end{align}
Using this result, we can express \(A(x,p)\) in terms of the ladder
operators \(\hat{a}\), \(\hat{a}^\dagger\). Finally, \(\langle A(x,p)\rangle\) can be
computed using the known action of \(\hat{a}\), \(\hat{a}^\dagger\) (or the
Hamiltonian \(\hat H\) if it is more convenient) on \(\phi_n(x)\) and the
orthonormality of \(\phi_n(x)\).
For example, let us compute the expectation value of position in the \(n\)-th stationary wave function as follows
\begin{align}
\langle x \rangle & = \sqrt{\frac{\hbar}{2m\omega}} \langle \phi_n,(\hat{a}+\hat{a}^\dagger) \phi_n \rangle \\ \nonumber
& = \sqrt{\frac{\hbar}{2m\omega}} \langle \phi_n, \sqrt{n} \, \phi_{n-1} +\sqrt{n+1} \, \phi_{n+1} \rangle \\
& = \sqrt{\frac{\hbar}{2m\omega}} ( \sqrt{n} \, \delta_{n,n-1} +\sqrt{n+1} \, \delta_{n,n+1}) \\
& = 0 \, .
\end{align}
The expectation value of position squared is computed similarly,
\begin{align}
\langle x^2 \rangle & = \frac{\hbar}{2m\omega} \langle \phi_n,(\hat{a}+\hat{a}^\dagger)^2 \phi_n \rangle \\ \nonumber
& = \frac{\hbar}{2m\omega} \langle \phi_n,(\hat{a}^2+a^{\dagger 2} + \hat{a}\hat{a}^\dagger+\hat{a}^\dagger \hat{a}) \phi_n \rangle \\
& = \frac{\hbar}{2m\omega} \langle \phi_n,(\hat{a}^2+a^{\dagger 2}+ 2\hat{a}^\dagger \hat{a}+1) \phi_n \rangle \\
& = \frac{\hbar}{2m\omega} ( \sqrt{n(n-1)}\delta_{n,n-2}+\sqrt{(n+1)(n+2)}\delta_{n,n+2}+ (2n+1)\delta_{n,n} ) \\
& = \frac{\hbar}{2m\omega} (2n+1) \\
& = \frac{\hbar}{m\omega}\left(n+\frac1 2\right) \, .
\end{align}
By similar computations, the expectation values of momentum and momentum squared are
\begin{align}
\langle p\rangle =0\,, \qquad \langle p^2 \rangle = \hbar m \omega\left(n+\frac1 2\right) \, .
\end{align}
Note the following points: