a : float
        thickness of the well in units of meters
    m : float
        effective mass in the well as a fraction of the electron mass
    U : float
        the potential in eV
    n : int
        the quantum number of the desired state

    If U <= 0, returns 0. Otherwise, returns the confinement energy in
    units of eV.

    Reference:
    D.L. Aronstein and C.R. Stroud, Jr., Am. J. Phys. 68, 943 (2000).

def finite_well_energy(a, m, U, n=1):
    '''
    a : float
        thickness of the well in units of meters
    m : float
        effective mass in the well as a fraction of the electron mass
    U : float
        the potential in eV
    n : int
        the quantum number of the desired state

    If U <= 0, returns 0. Otherwise, returns the confinement energy in
    units of eV.

    Reference:
    D.L. Aronstein and C.R. Stroud, Jr., Am. J. Phys. 68, 943 (2000).
    '''
    if U <= 0.:
        return 0
    P = prefactor * a * sqrt(m * U)
    print P, _finite_well_energy(P, n)
    return _finite_well_energy(P, n) * 7.61996e-20 / m / a ** 2.