The quantum states are derived from Quantum Mechanics. The maths involved is laid out here. If you notice anything that is unclear or inaccurate, please feel free to open an issue on GitHub.
The complete derivation is pretty gnarly. This section provides the solution only.
The wave function of the electron, , is described by
Where is the Associated Laguerre Polynomial, defined by: is the Laguerre Polynomial, defined byFor our purposes, it is easier to work with the Laguerre Polynomial in closed form. Note this differs by a factor of from the form often used by Mathmeticians.The Spherical Harmonic is defined byWhere for and otherwise. is an associated Legendre Polynomial, defined byand is the Legendre Polynomial, defined byOnce again, in our case, the explicit representation is easiest to work with: