# How to change coordinates of a differential operator?

I'm doing a basic quantum mechanics problem and am trying to learn how to do it in Mathematica. Any help would be much appreciated.

$\vec{L} = \vec{x} \times \vec{p}$

where $\vec{x}$ has components:

\begin{align*} x &= r \sin \theta \cos \phi\\ y &= r \sin \theta \sin \phi\\ z &= r \cos \theta \end{align*}

and $\vec{p}$ has components:

$p_x = - i \hbar \dfrac{\partial}{\partial x}$

etc.

Show that $L_z = -i \hbar \dfrac{\partial}{\partial \phi}$

-
where have you gotten stuck? –  acl Nov 9 '12 at 22:41
You can use this for a start. –  b.gatessucks Nov 9 '12 at 22:47

Here is the Mathematica proof. I'll leave out the prefactor $\hbar/i$ for simplicity. Also, in case this is a homework problem, I decided not to add too many comments to the code. Instead I'll let you figure it out. The basic idea is to do cross products and gradients in spherical coordinates. The calculation shown here actually gives you a way to calculate all angular momentum components (not just the $z$ component).

In terms of notation, I use the spherical coordinates r, θ, φ and call their unit vectors er, eθ, eφ.

Needs["VectorAnalysis"]

Clear[r, θ, φ]

SetCoordinates[Spherical[r, θ, φ]]

(* ==> Spherical[r, θ, φ] *)

{er, eθ, eφ} =
Transpose[JacobianMatrix[{r, θ, φ}]]/
ScaleFactors[{r, θ, φ}]


$\left( \begin{array}{ccc} \cos (\phi ) \sin (\theta ) & \sin (\theta ) \sin (\phi ) & \cos (\theta ) \\ \cos (\theta ) \cos (\phi ) & \cos (\theta ) \sin (\phi ) & -\sin (\theta ) \\ -\sin (\phi ) & \cos (\phi ) & 0 \\ \end{array} \right)$

l =
FullSimplify@
Cross[r er,


$\left( \begin{array}{c} \cot (\theta ) (-\cos (\phi )) f^{(0,1)}(\theta ,\phi )-\sin (\phi ) f^{(1,0)}(\theta ,\phi )\\ \cos (\phi ) f^{(1,0)}(\theta ,\phi )-\cot (\theta ) \sin (\phi ) f^{(0,1)}(\theta ,\phi )\\ f^{(0,1)}(\theta ,\phi) \end{array} \right)$

This is a list of Cartesian components (because the Cross product needed to be done in Cartesian coordinates) - the last entry in the list l is the z component of the angular momentum.

Here f is a test function to which I apply the operator. $f^{(0,1)}(\theta ,\phi)$ is the derivative with respect to the azimuthal coordinate.

The spherical components of the angular momentum (which you didn't ask for, but I mentioned in an earlier version of this answer) are obtained as follows:

FullSimplify[{er, eθ , eφ}.l]


$\left(0,-\csc (\theta ) f^{(0,1)}(\theta ,\varphi ),f^{(1,0)}(\theta ,\varphi )\right)$

Edit for version 9

Although the above solution still works if you load the VectorAnalysis package, there are compatibility warnings now because the package has become obsolete with Mathematica version 9. So for this new version it's better to extract the coordinate transformation data in a different way:

{er, eθ, eφ} =
CoordinateTransformData[{"Spherical" -> "Cartesian"},
"OrthonormalBasisRotation", {r, θ, φ}];
l = FullSimplify@
Cross[r er,

The result is the same as above. Typing the lengthy "OrthonormalBasisRotation" expression to define the orthonormal basis vectors of the spherical coordinate system takes some getting used to. It's almost equally easy to re-derive them from first principles - but I wanted to show where the obsolete JacobianMatrix and ScaleFactors` information is hidden now.