# Peeter Joot's Blog.

• ## Recent Comments

 ivor on Just Energy Canada nasty busin… A final pre-exam upd… on An updated compilation of note… Anon on About peeterjoot on About Anon on About
• ## People not reading this blog: 6,973,738,433 minus:

• 132,567 hits

# Archive for August 27th, 2009

## Bivector form of quantum angular momentum operator (derivatives of spherical polar unit vectors and bivectors)

Posted by peeterjoot on August 27, 2009

[Click here for a PDF of this sequence of posts with nicer formatting]

# Applying the vector derivative commutator (or not).

Let’s express the $\hat{\boldsymbol{\theta}}$ and $\hat{\boldsymbol{\phi}}$ unit vectors explicitly in terms of the standard basis. Starting with $\hat{\boldsymbol{\theta}}$ we have

\begin{aligned}\hat{\boldsymbol{\theta}} &= \tilde{R} \mathbf{e}_1 R \\ &= e^{-\mathbf{e}_{12}\phi/2} e^{-\mathbf{e}_{31}\theta/2} \mathbf{e}_1 e^{\mathbf{e}_{31}\theta/2} e^{\mathbf{e}_{12}\phi/2} \\ &= e^{-\mathbf{e}_{12}\phi/2} \mathbf{e}_1 e^{\mathbf{e}_{31}\theta} e^{\mathbf{e}_{12}\phi/2} \\ &= e^{-\mathbf{e}_{12}\phi/2} (\mathbf{e}_1 \cos\theta -\mathbf{e}_3 \sin\theta) e^{\mathbf{e}_{12}\phi/2} \\ &= \mathbf{e}_1 \cos\theta e^{\mathbf{e}_{12}\phi} -\mathbf{e}_3 \sin\theta \end{aligned}

Explicitly in vector form, eliminating the exponential, this is $\hat{\boldsymbol{\theta}} = \mathbf{e}_1 \cos\theta \cos\phi + \mathbf{e}_2 \cos\theta\sin\phi - \mathbf{e}_3\sin\theta$, but it is more convenient to keep the exponential as is.

For $\hat{\boldsymbol{\phi}}$ we have

\begin{aligned}\hat{\boldsymbol{\phi}} &= \tilde{R} \mathbf{e}_2 R \\ &= e^{-\mathbf{e}_{12}\phi/2} e^{-\mathbf{e}_{31}\theta/2} \mathbf{e}_2 e^{\mathbf{e}_{31}\theta/2} e^{\mathbf{e}_{12}\phi/2} \\ &= e^{-\mathbf{e}_{12}\phi/2} \mathbf{e}_2 e^{\mathbf{e}_{12}\phi/2} \\ &= \mathbf{e}_2 e^{\mathbf{e}_{12}\phi} \\ \end{aligned}

Again, explicitly this is $\hat{\boldsymbol{\phi}} = \mathbf{e}_2 \cos\phi - \mathbf{e}_1 \sin\phi$, but we’ll use the exponential form above. Last we want $\hat{\mathbf{r}}$

\begin{aligned}\hat{\mathbf{r}} &= \tilde{R} \mathbf{e}_3 R \\ &= e^{-\mathbf{e}_{12}\phi/2} e^{-\mathbf{e}_{31}\theta/2} \mathbf{e}_3 e^{\mathbf{e}_{31}\theta/2} e^{\mathbf{e}_{12}\phi/2} \\ &= e^{-\mathbf{e}_{12}\phi/2} \mathbf{e}_3 e^{\mathbf{e}_{31}\theta} e^{\mathbf{e}_{12}\phi/2} \\ &= e^{-\mathbf{e}_{12}\phi/2} (\mathbf{e}_3 \cos\theta + \mathbf{e}_1 \sin\theta) e^{\mathbf{e}_{12}\phi/2} \\ &= \mathbf{e}_3 \cos\theta + \mathbf{e}_1 \sin\theta e^{\mathbf{e}_{12}\phi} \\ \end{aligned}

Summarizing we have

\begin{aligned}\hat{\boldsymbol{\theta}} &= \mathbf{e}_1 \cos\theta e^{\mathbf{e}_{12}\phi} -\mathbf{e}_3 \sin\theta \\ \hat{\boldsymbol{\phi}} &= \mathbf{e}_2 e^{\mathbf{e}_{12}\phi} \\ \hat{\mathbf{r}} &= \mathbf{e}_3 \cos\theta + \mathbf{e}_1 \sin\theta e^{\mathbf{e}_{12}\phi} \end{aligned} \quad\quad\quad(22)

Or without exponentials

\begin{aligned}\hat{\boldsymbol{\theta}} &= \mathbf{e}_1 \cos\theta \cos\phi + \mathbf{e}_2 \cos\theta\sin\phi - \mathbf{e}_3\sin\theta \\ \hat{\boldsymbol{\phi}} &= \mathbf{e}_2 \cos\phi - \mathbf{e}_1 \sin\phi \\ \hat{\mathbf{r}} &= \mathbf{e}_3 \cos\theta + \mathbf{e}_1 \sin\theta \cos\phi + \mathbf{e}_2 \sin\theta \sin\phi \end{aligned} \quad\quad\quad(25)

Now, having worked out the cool commutator result, it appears that it will actually be harder to use it, then to just calculate the derivatives directly (at least for the $\hat{\boldsymbol{\phi}}$ derivatives). For those we have

\begin{aligned}\partial_\theta \hat{\boldsymbol{\phi}} &= \partial_\theta \mathbf{e}_2 e^{\mathbf{e}_{12}\phi} \\ &= 0 \end{aligned}

and

\begin{aligned}\partial_\phi \hat{\boldsymbol{\phi}} &= \partial_\phi \mathbf{e}_2 e^{\mathbf{e}_{12}\phi} \\ &= \mathbf{e}_2 \mathbf{e}_{12} e^{\mathbf{e}_{12}\phi} \\ &= -\mathbf{e}_{12} \hat{\boldsymbol{\phi}} \end{aligned}

This multiplication takes $\hat{\boldsymbol{\phi}}$ a vector in the $x,y$ plane and rotates it 90 degrees, leaving an inwards facing radial unit vector in the x,y plane.

Now, having worked out the commutator method, lets at least verify that it works.

\begin{aligned}\partial_\theta \hat{\boldsymbol{\phi}} &= \left[{\hat{\boldsymbol{\phi}}},{\Omega_\theta}\right] \\ &= \hat{\boldsymbol{\phi}} \Omega_\theta - \Omega_\theta \hat{\boldsymbol{\phi}} \\ &= \frac{1}{{2}} (\hat{\boldsymbol{\phi}} \mathbf{e}_{31} e^{\mathbf{e}_{12}\phi} - \mathbf{e}_{31} e^{\mathbf{e}_{12}\phi} \hat{\boldsymbol{\phi}}) \\ &= \frac{1}{{2}} (\mathbf{e}_2 \mathbf{e}_3 \mathbf{e}_1 e^{-\mathbf{e}_{12}\phi} e^{\mathbf{e}_{12}\phi} - \mathbf{e}_{3} \mathbf{e}_{1} \mathbf{e}_{2} e^{-\mathbf{e}_{12}\phi} e^{\mathbf{e}_{12}\phi}) \\ &= \frac{1}{{2}} (-\mathbf{e}_3 \mathbf{e}_2 \mathbf{e}_1 - \mathbf{e}_{3} \mathbf{e}_{1} \mathbf{e}_{2} ) \\ &= 0 \end{aligned}

Much harder this way compared to taking the derivative directly, but we at least get the right answer. For the $\phi$ derivative using the commutator we have

\begin{aligned}\partial_\phi \hat{\boldsymbol{\phi}} &= \left[{\hat{\boldsymbol{\phi}}},{\Omega_\phi}\right] \\ &= \hat{\boldsymbol{\phi}} \Omega_\phi - \Omega_\phi \hat{\boldsymbol{\phi}} \\ &= \frac{1}{{2}} (\hat{\boldsymbol{\phi}} \mathbf{e}_{12} - \mathbf{e}_{12} \hat{\boldsymbol{\phi}}) \\ &= \frac{1}{{2}} (\mathbf{e}_2 e^{\mathbf{e}_{12}\phi} \mathbf{e}_{12} - \mathbf{e}_{12} \mathbf{e}_2 e^{\mathbf{e}_{12}\phi}) \\ &= \frac{1}{{2}} (-\mathbf{e}_{12} \mathbf{e}_2 e^{\mathbf{e}_{12}\phi} - \mathbf{e}_{12} \mathbf{e}_2 e^{\mathbf{e}_{12}\phi}) \\ &= -\mathbf{e}_{12} \hat{\boldsymbol{\phi}} \end{aligned}

Good, also consistent with direct calculation. How about our $\hat{\boldsymbol{\theta}}$ derivatives? Lets just calculate these directly without bothering at all with the commutator. This is

\begin{aligned}\partial_\phi \hat{\boldsymbol{\theta}} &= \mathbf{e}_1 \cos\theta \mathbf{e}_12 e^{\mathbf{e}_{12}\phi} \\ &= \mathbf{e}_2 \cos\theta e^{\mathbf{e}_{12}\phi} \\ &= \cos\theta \hat{\boldsymbol{\phi}} \end{aligned}

and

\begin{aligned}\partial_\theta \hat{\boldsymbol{\theta}} &= -\mathbf{e}_1 \sin\theta e^{\mathbf{e}_{12}\phi} -\mathbf{e}_3 \cos\theta \\ &= -\mathbf{e}_{12} \sin\theta \hat{\boldsymbol{\phi}} -\mathbf{e}_3 \cos\theta \\ \end{aligned}

Finally, last we have the derivatives of $\hat{\mathbf{r}}$. Those are

\begin{aligned}\partial_\phi \hat{\mathbf{r}} &= \mathbf{e}_2 \sin\theta e^{\mathbf{e}_{12}\phi} \\ &= \sin\theta \hat{\boldsymbol{\phi}} \end{aligned}

and

\begin{aligned}\partial_\theta \hat{\mathbf{r}} &= -\mathbf{e}_3 \sin\theta + \mathbf{e}_1 \cos\theta e^{\mathbf{e}_{12}\phi} \\ &= -\mathbf{e}_3 \sin\theta + \mathbf{e}_{12} \cos\theta \hat{\boldsymbol{\phi}} \\ \end{aligned}

Summarizing, all the derivatives we need to evaluate the square of the angular momentum operator are

\begin{aligned}\partial_\theta \hat{\boldsymbol{\phi}} &= 0 \\ \partial_\phi \hat{\boldsymbol{\phi}} &= -\mathbf{e}_{12} \hat{\boldsymbol{\phi}} \\ \partial_\theta \hat{\boldsymbol{\theta}} &= -\mathbf{e}_{12} \sin\theta \hat{\boldsymbol{\phi}} -\mathbf{e}_3 \cos\theta \\ \partial_\phi \hat{\boldsymbol{\theta}} &= \cos\theta \hat{\boldsymbol{\phi}} \\ \partial_\theta \hat{\mathbf{r}} &= -\mathbf{e}_3 \sin\theta + \mathbf{e}_{12} \cos\theta \hat{\boldsymbol{\phi}} \\ \partial_\phi \hat{\mathbf{r}} &= \sin\theta \hat{\boldsymbol{\phi}} \end{aligned} \quad\quad\quad(28)

Bugger. We actually want the derivatives of the bivectors $\hat{\mathbf{r}}\hat{\boldsymbol{\theta}}$ and $\hat{\mathbf{r}}\hat{\boldsymbol{\phi}}$ so we aren’t ready to evaluate the squared angular momentum. There’s three choices, one is to use these results and apply the chain rule, or start over and directly take the derivatives of these bivectors, or use the commutator result (which didn’t actually assume vectors and we can apply it to bivectors too if we really wanted to).

An attempt to use the chain rule get messy, but it looks like the bivectors reduce nicely, making it pointless to even think about the commutator method. Introducing some notational conveniences, first write $i = \mathbf{e}_{12}$. We’ll have to be a bit careful with this since it commutes with $\mathbf{e}_3$, but anticommutes with $\mathbf{e}_1$ or $\mathbf{e}_2$ (and therefore $\hat{\boldsymbol{\phi}}$). As usual we also write $I = \mathbf{e}_1 \mathbf{e}_2 \mathbf{e}_3$ for the Euclidean pseudoscalar (which commutes with all vectors and bivectors).

\begin{aligned}\hat{\mathbf{r}} \hat{\boldsymbol{\theta}}&= (\mathbf{e}_3 \cos\theta + i \sin\theta \hat{\boldsymbol{\phi}})(\cos\theta i \hat{\boldsymbol{\phi}} - \mathbf{e}_3 \sin\theta) \\ &= \mathbf{e}_3 \cos^2\theta i \hat{\boldsymbol{\phi}} -i \sin^2\theta \hat{\boldsymbol{\phi}} \mathbf{e}_3 +(i \hat{\boldsymbol{\phi}} i \hat{\boldsymbol{\phi}} -\mathbf{e}_3 \mathbf{e}_3 ) \cos\theta \sin\theta \\ &= i \mathbf{e}_3 (\cos^2\theta + \sin^2\theta) \hat{\boldsymbol{\phi}} +(-\hat{\boldsymbol{\phi}} i^2 \hat{\boldsymbol{\phi}} - 1) \cos\theta \sin\theta \\ \end{aligned}

This gives us just

\begin{aligned}\hat{\mathbf{r}} \hat{\boldsymbol{\theta}} = I \hat{\boldsymbol{\phi}} \end{aligned} \quad\quad\quad(34)

and calculation of the bivector partials will follow exclusively from the $\hat{\boldsymbol{\phi}}$ partials tabulated above.

Our other bivector doesn’t reduce quite as cleanly. We have

\begin{aligned}\hat{\mathbf{r}} \hat{\boldsymbol{\phi}} &=(\mathbf{e}_3 \cos\theta + i \sin\theta \hat{\boldsymbol{\phi}}) \hat{\boldsymbol{\phi}} \\ \end{aligned}

So for this one we have

\begin{aligned}\hat{\mathbf{r}} \hat{\boldsymbol{\phi}} = \mathbf{e}_3 \hat{\boldsymbol{\phi}} \cos\theta + i \sin\theta \end{aligned} \quad\quad\quad(35)

Tabulating all the bivector derivatives (details omitted) we have

\begin{aligned}\partial_\theta (\hat{\mathbf{r}} \hat{\boldsymbol{\theta}}) &= 0 \\ \partial_\phi (\hat{\mathbf{r}} \hat{\boldsymbol{\theta}}) &= \mathbf{e}_3 \hat{\boldsymbol{\phi}} \\ \partial_\theta (\hat{\mathbf{r}} \hat{\boldsymbol{\phi}}) &= -\mathbf{e}_3 \hat{\boldsymbol{\phi}} \sin\theta + i \cos\theta = i e^{I\hat{\boldsymbol{\phi}}\theta} \\ \partial_\phi (\hat{\mathbf{r}} \hat{\boldsymbol{\phi}}) &= -I \hat{\boldsymbol{\phi}} \cos\theta \end{aligned} \quad\quad\quad(36)

Okay, we are now armed to do the squaring of the angular momentum, but once again it’s late to start now. To be continued.

## perl regex tricks. Non capturing expressions and alternatives.

Posted by peeterjoot on August 27, 2009

Have two sets of dump output to compare, and both have the occasional pointer dumped which messes up the diff. I want to mask the pointer output (all starting with 0x) on all the lines like:

 List Entry Address:           0x...
List Tail (primary):             0x...
List Tail (secondary):           0x...
Next entry name collision:    0x...
Next entry PLEID collision:   0x...
Next entry (primary):         0x...
Next entry (secondary):       0x...
Previous entry (primary):     0x...
Previous entry (secondary):   0x...


An easy way would be to run ‘grep -v’ and just filter these out completely, but I wanted the original line numbers to stay intact for reference.

Here’s a one liner perl script, executed with ‘perl -pi ./myScript *.fmt’ (where the files *.fmt are what I’m mucking with) :

$cat myScript s/((?i:Next|List|previous) (?i:entry|head|tail).*0x).*/$1................/;


Since I had to lookup (man perlre) how to do this once again, it’s a good blog topic for self reference. Let’s break it down. First thing is an outermost capturing pattern

s/(stuff.*0x).*/$1................/;  this says match ‘stuff.*0x’, namely ‘stuff’ followed by anything (the .* part), then ’0x’, then anything. All of this within the braces goes into$1, so the replacement is everything on the line except whatever follows 0x (and for that I replaced with 16 dots). Now look at the nested expression before the .*0x part:

(?i:Next|List|previous) (?i:entry|head|tail)


More perl ASCII barf starting things off, but it’s not so bad. If you have an expression like (?:stuff) it means match ‘stuff’ but don’t capture it (i.e. don’t put it in $2 or$3, …). Only slightly more complex is having alternatives in the pattern, so something like (?:Next|List) means match Next or match List, but also don’t put anything into a $N variable. There’s one more bit in there unexplained, the ‘i’ modifier flag. This is a way to add case Insensitive to the pattern. In this case I could have made that a global flag at the end of the replace specification so it would apply to the whole pattern: s/((?:Next|List|previous) (?:entry|head|tail).*0x).*/$1................/i;


but initially I had the case Insensitive modifier only on one of the patterns, so the final result ended up with some redundancy.

Posted in perl and general scripting hackery | Tagged: , | Leave a Comment »