I am trying to code a 3D representation of the position wavefunction probability of the Hydrogen atom.
I am having issues with the angular terms of the equation, which is represented as the real part of a spherical harmonic function.
And the Associated Legendre function is:
I do the corresponding derivative (d/d_theta of cos(theta) of the function) for modes l=0 to l=3 through these tabulated equations:
The final term: e^(i * m * phi) I represent with: sin(|m| * phi) if m < 0 and cos(m * phi) if m > 0.
After converting to cartesian coordinates, I end up with a 3D visual that looks like this:
The x-z axis is actually quite good, as it matches what is expected from 2D cross-sections I found online:
However, there is a discontinuity in the y-axis which should not be there.
By the way, theta ranges from 0-2pi and phi ranges from 0-pi. r is a constant in this case.
Is there anywhere in the math which I did incorrectly?