# 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}$

-

1
where have you gotten stuck? – acl Nov 9 '12 at 22:41

2
– b.gatessucks Nov 9 '12 at 22:47

## 1 Answer

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, 
   Transpose[{er, eθ, eφ}].Grad[f[θ, φ]]]
````

$\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, 
   Transpose[{er, eθ, eφ}].Grad[
     f[θ, φ], {r, θ, φ}, 
     "Spherical"]]
````

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.

-

Thank you for your thorough explanation! This was in fact a homework problem, though I had solved it on paper already. – TaylorR137 Nov 12 '12 at 22:11
lang-mma
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 12, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 20, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.8997900485992432, "perplexity_flag": "middle"}