Did I find the right examples for you? yes no      Crawl my project      Python Jobs

# sympy.physics.qho_1d.psi_n

All Samples(5)  |  Call(4)  |  Derive(0)  |  Import(1)
```Returns the wavefunction psi_{n} for the One-dimensional harmonic oscillator.

``n``
the "nodal" quantum number.  Corresponds to the number of nodes in the
wavefunction.  n >= 0
``x``
x coordinate
``m``
mass of the particle
``omega``(more...)
```

```        def psi_n(n, x, m, omega):
"""
Returns the wavefunction psi_{n} for the One-dimensional harmonic oscillator.

``n``
the "nodal" quantum number.  Corresponds to the number of nodes in the
wavefunction.  n >= 0
``x``
x coordinate
``m``
mass of the particle
``omega``
angular frequency of the oscillator

Examples
========

>>> from sympy.physics.qho_1d import psi_n
>>> from sympy import var
>>> var("x m omega")
(x, m, omega)
>>> psi_n(0, x, m, omega)
(m*omega)**(1/4)*exp(-m*omega*x**2/(2*hbar))/(hbar**(1/4)*pi**(1/4))

"""

# sympify arguments
n, x, m, omega = map(S, [n, x, m, omega])
nu = m * omega / hbar
# normalization coefficient
C = (nu/pi)**(S(1)/4) * sqrt(1/(2**n*factorial(n)))

return C * exp(-nu* x**2 /2) * hermite(n, sqrt(nu)*x)
```

```from sympy import exp, integrate, oo, Rational, pi, S, simplify, sqrt
from sympy.abc import omega, m, x
from sympy.physics.qho_1d import psi_n, E_n
from sympy.physics.quantum.constants import hbar

```
```    }
for n in Psi:
assert simplify(psi_n(n, x, m, omega) - Psi[n]) == 0

def test_norm(n=1):
# Maximum "n" which is tested:
for i in range(n + 1):
assert integrate(psi_n(i, x, 1, 1)**2, (x, -oo, oo)) == 1
```
```        for j in range(i + 1, n + 1):
assert integrate(
psi_n(i, x, 1, 1)*psi_n(j, x, 1, 1), (x, -oo, oo)) == 0

```