Solving the Radial Function of the Hydrogen Atom with Python

Rhett Allain
9 min readNov 27, 2023
Not a real hydrogen atom — just a diagram.

The best thing in a quantum mechanics course is solving for the wave function of a hydrogen atom. It’s great because it’s possible to get an analytical solution to this problem in terms of some functions. For all the other atoms, we have to cheat or make some approximations. Historically, this is a big deal.

The worst thing in a quantum mechanics course is ALSO the hydrogen atom. Yes, it’s true that we can find a solution to the wave function — but we have to use spherical coordinates and things get messy.

Honestly, I think that in an undergraduate course the full solution is a little bit too much. However, it’s possible to get a differential equation for just the radial part of this function and then solve this equation using python and the shooting method.

The Hydrogen Atom

Let’s start with the hydrogen atom. It’s an electron interacting with a proton. Of course we need to write an expression for both the kinetic and potential energy — the potential energy would be the following.

Yes, I know that we normally use U for the potential energy — but for some reason, everyone use V in quantum mechanics. Whatever. Just a couple of things to point out. The two charges are +e and -e (for the proton and the electron). Also, I’m going to let k be all that constant stuff. Oh, one more thing — I’m going to assume that the proton is stationary and so we only have to deal with the electron.

Next, we need to write the Schrödinger equation.

H is the Hamiltonian — the sum of kinetic and potential energy. Here we can write the kinetic energy in terms of the momentum operator which has a second derivative with respect to space. Since we are dealing with 3 dimensions here, that derivative is written as the Laplacian.

Yes, the Laplacian in Cartesian coordinates is very easy to deal with. However, our potential depends only on r — the distance from the hydrogen atom (which would depend on x, y, and z). It’s going to be easiest to use spherical coordinates instead. Here’s that darn…



Rhett Allain

Physics faculty, science blogger of all things geek. Technical Consultant for CBS MacGyver and MythBusters. WIRED blogger.