Peeter Joot's (OLD) Blog.

Math, physics, perl, and programming obscurity.

Archive for July, 2009

Transverse electric and magnetic fields

Posted by peeterjoot on July 31, 2009

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

Motivation

In Eli’s Transverse Electric and Magnetic Fields in a Conducting Waveguide blog entry he works through the algebra calculating the transverse components, the perpendicular to the propagation direction components.

This should be possible using Geometric Algebra too, and trying this made for a good exercise.

Setup

The starting point can be the same, the source free Maxwell’s equations. Writing \partial_0 = (1/c) \partial/{\partial t}, we have

\begin{aligned}\boldsymbol{\nabla} \cdot \mathbf{E} &= 0 \\ \boldsymbol{\nabla} \cdot \mathbf{B} &= 0 \\ \boldsymbol{\nabla} \times \mathbf{E} &= - \partial_0 \mathbf{B} \\ \boldsymbol{\nabla} \times \mathbf{B} &= \mu \epsilon \partial_0 \mathbf{E} \end{aligned} \quad\quad\quad(1)

Multiplication of the last two equations by the spatial pseudoscalar I, and using I \mathbf{a} \times \mathbf{b} = \mathbf{a} \wedge \mathbf{b}, the curl equations can be written in their dual bivector form

\begin{aligned}\boldsymbol{\nabla} \wedge \mathbf{E} &= - \partial_0 I \mathbf{B} \\ \boldsymbol{\nabla} \wedge \mathbf{B} &= \mu \epsilon \partial_0 I \mathbf{E} \end{aligned} \quad\quad\quad(5)

Now adding the dot and curl equations using \mathbf{a} \mathbf{b} = \mathbf{a} \cdot \mathbf{b} + \mathbf{a} \wedge \mathbf{b} eliminates the cross products

\begin{aligned}\boldsymbol{\nabla} \mathbf{E} &= - \partial_0 I \mathbf{B} \\ \boldsymbol{\nabla} \mathbf{B} &= \mu \epsilon \partial_0 I \mathbf{E} \end{aligned} \quad\quad\quad(7)

These can be further merged without any loss, into the GA first order equation

\begin{aligned}\left(\boldsymbol{\nabla} + \frac{\sqrt{\mu\epsilon}}{c}\partial_t\right) \left(\mathbf{E} + \frac{I\mathbf{B}}{\sqrt{\mu\epsilon}} \right) = 0 \end{aligned} \quad\quad\quad(9)

We are really after solutions to the total multivector field F = \mathbf{E} + I \mathbf{B}/\sqrt{\mu\epsilon}. For this problem where separate electric and magnetic field components are desired, working from (7) is perhaps what we want?

Following Eli and Jackson, write \boldsymbol{\nabla} = \boldsymbol{\nabla}_t + \hat{\mathbf{z}} \partial_z, and

\begin{aligned}\mathbf{E}(x,y,z,t) &= \mathbf{E}(x,y) e^{\pm i k z - i \omega t} \\ \mathbf{B}(x,y,z,t) &= \mathbf{B}(x,y) e^{\pm i k z - i \omega t} \end{aligned} \quad\quad\quad(10)

Evaluating the z and t partials we have

\begin{aligned}(\boldsymbol{\nabla}_t \pm i k \hat{\mathbf{z}}) \mathbf{E}(x,y) &= \frac{i\omega}{c} I \mathbf{B}(x,y) \\ (\boldsymbol{\nabla}_t \pm i k \hat{\mathbf{z}}) \mathbf{B}(x,y) &= -\mu \epsilon \frac{i\omega}{c} I \mathbf{E}(x,y) \end{aligned} \quad\quad\quad(12)

For the remainder of these notes, the explicit (x,y) dependence will be assumed for \mathbf{E} and \mathbf{B}.

An obvious thing to try with these equations is just substitute one into the other. If that’s done we get the pair of second order harmonic equations

\begin{aligned}{\boldsymbol{\nabla}_t}^2\begin{pmatrix}\mathbf{E} \\  \mathbf{B} \end{pmatrix}= \left( k^2 - \mu \epsilon \frac{\omega^2}{c^2} \right)\begin{pmatrix}\mathbf{E} \\  \mathbf{B} \end{pmatrix} \end{aligned} \quad\quad\quad(14)

One could consider the problem solved here. Separately equating both sides of this equation to zero, we have the k^2 = \mu\epsilon \omega^2/c^2 constraint on the wave number and angular velocity, and the second order Laplacian on the left hand side is solved by the real or imaginary parts of any analytic function. Especially when one considers that we are after a multivector field that of intrinsic complex nature.

However, that is not really what we want as a solution. Doing the same on the unified Maxwell equation (9), we have

\begin{aligned}\left(\boldsymbol{\nabla}_t \pm i k \hat{\mathbf{z}} - \sqrt{\mu\epsilon}\frac{i\omega}{c}\right) \left(\mathbf{E} + \frac{I\mathbf{B}}{\sqrt{\mu\epsilon}} \right) = 0 \end{aligned} \quad\quad\quad(15)

Selecting scalar, vector, bivector and trivector grades of this equation produces the following respective relations between the various components

\begin{aligned}0 = \left\langle{{\cdots}}\right\rangle &= \boldsymbol{\nabla}_t \cdot \mathbf{E} \pm i k \hat{\mathbf{z}} \cdot \mathbf{E} \\ 0 = {\left\langle{{\cdots}}\right\rangle}_{1} &= I \boldsymbol{\nabla}_t \wedge \mathbf{B}/\sqrt{\mu\epsilon} \pm i I k \hat{\mathbf{z}} \wedge \mathbf{B}/\sqrt{\mu\epsilon} - i \sqrt{\mu\epsilon}\frac{\omega}{c} \mathbf{E} \\ 0 = {\left\langle{{\cdots}}\right\rangle}_{2} &= \boldsymbol{\nabla}_t \wedge \mathbf{E} \pm i k \hat{\mathbf{z}} \wedge \mathbf{E} - i \frac{\omega}{c} I \mathbf{B} \\ 0 = {\left\langle{{\cdots}}\right\rangle}_{3} &= I \boldsymbol{\nabla}_t \cdot \mathbf{B}/\sqrt{\mu\epsilon} \pm i I k \hat{\mathbf{z}} \cdot \mathbf{B}/\sqrt{\mu\epsilon} \end{aligned} \quad\quad\quad(16)

From the scalar and pseudoscalar grades we have the propagation components in terms of the transverse ones

\begin{aligned}E_z &= \frac{\pm i}{k} \boldsymbol{\nabla}_t \cdot \mathbf{E}_t \\ B_z &= \frac{\pm i}{k} \boldsymbol{\nabla}_t \cdot \mathbf{B}_t  \end{aligned} \quad\quad\quad(20)

But this is the opposite of the relations that we are after. On the other hand from the vector and bivector grades we have

\begin{aligned}i \frac{\omega}{c} \mathbf{E} &= -\frac{1}{{\mu\epsilon}}\left(\boldsymbol{\nabla}_t \times \mathbf{B}_z \pm i k \hat{\mathbf{z}} \times \mathbf{B}_t\right) \\ i \frac{\omega}{c} \mathbf{B} &= \boldsymbol{\nabla}_t \times \mathbf{E}_z \pm i k \hat{\mathbf{z}} \times \mathbf{E}_t \end{aligned} \quad\quad\quad(22)

A clue from the final result.

From (22) and a lot of messy algebra we should be able to get the transverse equations. Is there a slicker way? The end result that Eli obtained suggests a path. That result was

\begin{aligned}\mathbf{E}_t = \frac{i}{\mu\epsilon \frac{\omega^2}{c^2} - k^2} \left( \pm k \boldsymbol{\nabla}_t E_z - \frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t B_z \right) \end{aligned} \quad\quad\quad(24)

The numerator looks like it can be factored, and after a bit of playing around a suitable factorization can be obtained:

\begin{aligned}{\left\langle{{ \left( \pm k + \frac{\omega}{c} \hat{\mathbf{z}} \right) \boldsymbol{\nabla}_t \hat{\mathbf{z}} \left( \mathbf{E}_z + I \mathbf{B}_z \right) }}\right\rangle}_{1}&={\left\langle{{ \left( \pm k + \frac{\omega}{c} \hat{\mathbf{z}} \right) \boldsymbol{\nabla}_t \left( E_z + I B_z \right) }}\right\rangle}_{1} \\ &=\pm k \boldsymbol{\nabla} E_z + \frac{\omega}{c} {\left\langle{{ I \hat{\mathbf{z}} \boldsymbol{\nabla}_t B_z }}\right\rangle}_{1} \\ &=\pm k \boldsymbol{\nabla} E_z + \frac{\omega}{c} I \hat{\mathbf{z}} \wedge \boldsymbol{\nabla}_t B_z \\ &=\pm k \boldsymbol{\nabla} E_z - \frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t B_z \\  \end{aligned}

Observe that the propagation components of the field \mathbf{E}_z + I\mathbf{E}_z can be written in terms of the symmetric product

\begin{aligned}\frac{1}{{2}} \left( \hat{\mathbf{z}} (\mathbf{E} + I\mathbf{B}) + (\mathbf{E} + I\mathbf{B}) \hat{\mathbf{z}} \right)&=\frac{1}{{2}} \left( \hat{\mathbf{z}} \mathbf{E} + \mathbf{E} \hat{\mathbf{z}} \right) + \frac{I}{2} \left( \hat{\mathbf{z}} \mathbf{B} + \mathbf{B} \hat{\mathbf{z}} + I \right) \\ &=\hat{\mathbf{z}} \cdot \mathbf{E} + I \hat{\mathbf{z}} \cdot \mathbf{B} \end{aligned}

Now the total field in CGS units was actually F = \mathbf{E} + I \mathbf{B}/\sqrt{\mu\epsilon}, not F = \mathbf{E} + I \mathbf{B}, so the factorization above isn’t exactly what we want. It does however, provide the required clue. We probably get the result we want by forming the symmetric product (a hybrid dot product selecting both the vector and bivector terms).

Symmetric product of the field with the direction vector.

Rearranging Maxwell’s equation (15) in terms of the transverse gradient and the total field F we have

\begin{aligned}\boldsymbol{\nabla}_t F = \left( \mp i k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{i\omega}{c}\right) F \end{aligned} \quad\quad\quad(25)

With this our symmetric product is

\begin{aligned}\boldsymbol{\nabla}_t ( F \hat{\mathbf{z}} + \hat{\mathbf{z}} F) &= (\boldsymbol{\nabla}_t F) \hat{\mathbf{z}} - \hat{\mathbf{z}} (\boldsymbol{\nabla}_t F) \\ &=\left( \mp i k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{i\omega}{c}\right) F \hat{\mathbf{z}}- \hat{\mathbf{z}} \left( \mp i k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{i\omega}{c}\right) F \\ &=i \left( \mp k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) (F \hat{\mathbf{z}} - \hat{\mathbf{z}} F) \\  \end{aligned}

The antisymmetric product on the right hand side should contain the desired transverse field components. To verify multiply it out

\begin{aligned}\frac{1}{{2}}(F \hat{\mathbf{z}} - \hat{\mathbf{z}} F)  &=\frac{1}{{2}}\left( \left(\mathbf{E} + I \mathbf{B}/\sqrt{\mu\epsilon}\right) \hat{\mathbf{z}} - \hat{\mathbf{z}} \left(\mathbf{E} + I \mathbf{B}/\sqrt{\mu\epsilon}\right) \right)  \\ &=\mathbf{E} \wedge \hat{\mathbf{z}} + I \mathbf{B}/\sqrt{\mu\epsilon} \wedge \hat{\mathbf{z}} \\ &=(\mathbf{E}_t + I \mathbf{B}_t/\sqrt{\mu\epsilon}) \hat{\mathbf{z}} \\  \end{aligned}

Now, with multiplication by the conjugate quantity -i(\pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\omega/c), we can extract these transverse components.

\begin{aligned}\left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \left( \mp k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) (F \hat{\mathbf{z}} - \hat{\mathbf{z}} F) &=\left( -k^2 + {\mu\epsilon}\frac{\omega^2}{c^2}\right) (F \hat{\mathbf{z}} - \hat{\mathbf{z}} F)  \end{aligned}

Rearranging, we have the transverse components of the field

\begin{aligned}(\mathbf{E}_t + I \mathbf{B}_t/\sqrt{\mu\epsilon}) \hat{\mathbf{z}} &=\frac{i}{k^2 - \mu\epsilon\frac{\omega^2}{c^2}} \left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \boldsymbol{\nabla}_t \frac{1}{{2}}( F \hat{\mathbf{z}} + \hat{\mathbf{z}} F)  \end{aligned} \quad\quad\quad(26)

With left multiplication by \hat{\mathbf{z}}, and writing F = F_t + F_z we have

\begin{aligned}F_t &= \frac{i}{k^2 - \mu\epsilon\frac{\omega^2}{c^2}} \left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \boldsymbol{\nabla}_t F_z \end{aligned} \quad\quad\quad(27)

While this is a complete solution, we can additionally extract the electric and magnetic fields to compare results with Eli’s calculation. We take
vector grades to do so with \mathbf{E}_t = {\left\langle{{F_t}}\right\rangle}_{1}, and \mathbf{B}_t/\sqrt{\mu\epsilon} = {\left\langle{{-I F_t}}\right\rangle}_{1}. For the transverse electric field

\begin{aligned}{\left\langle{{ \left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \boldsymbol{\nabla}_t (\mathbf{E}_z + I \mathbf{B}_z/\sqrt{/\mu\epsilon}) }}\right\rangle}_{1} &=\pm k \hat{\mathbf{z}} (-\hat{\mathbf{z}}) \boldsymbol{\nabla}_t E_z + \frac{\omega}{c} \underbrace{{\left\langle{{I \boldsymbol{\nabla}_t \hat{\mathbf{z}}}}\right\rangle}_{1}}_{-I^2 \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t } B_z \\ &=\mp k \boldsymbol{\nabla}_t E_z + \frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t B_z \\  \end{aligned}

and for the transverse magnetic field

\begin{aligned}{\left\langle{{ -I \left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \boldsymbol{\nabla}_t (\mathbf{E}_z + I \mathbf{B}_z/\sqrt{\mu\epsilon}) }}\right\rangle}_{1} &=-I \sqrt{\mu\epsilon}\frac{\omega}{c} \boldsymbol{\nabla}_t \mathbf{E}_z+{\left\langle{{ \left( \pm k \hat{\mathbf{z}} + \sqrt{\mu\epsilon}\frac{\omega}{c}\right) \boldsymbol{\nabla}_t \mathbf{B}_z/\sqrt{\mu\epsilon} }}\right\rangle}_{1}  \\ &=- \sqrt{\mu\epsilon}\frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t E_z\mp k \boldsymbol{\nabla}_t B_z/\sqrt{\mu\epsilon} \\  \end{aligned}

Thus the split of transverse field into the electric and magnetic components yields

\begin{aligned}\mathbf{E}_t &= \frac{i}{k^2 - \mu\epsilon\frac{\omega^2}{c^2}} \left( \mp k \boldsymbol{\nabla}_t E_z + \frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t B_z \right) \\ \mathbf{B}_t &= \frac{i}{k^2 - \mu\epsilon\frac{\omega^2}{c^2}} \left( - {\mu\epsilon}\frac{\omega}{c} \hat{\mathbf{z}} \times \boldsymbol{\nabla}_t E_z \mp k \boldsymbol{\nabla}_t B_z \right)  \end{aligned} \quad\quad\quad(28)

Compared to Eli’s method using messy traditional vector algebra, this method also has a fair amount of messy tricky algebra, but of a different sort.

Advertisements

Posted in Math and Physics Learning. | Tagged: , , , , , | Leave a Comment »

perl -p … one of the handiest one liner commands

Posted by peeterjoot on July 29, 2009

Suppose you have a list of files:

$ cat r
/vbs/engn/include/sqlbgbc_inlines.h
/vbs/engn/include/sqlekrcb.h
/vbs/engn/sqb/sqlbenvi.C

that you want to make a systematic simple change to, replacing all instances of some pattern with another. For illustration purposes, suppose that replacement is a straight replacement of the simplest sort changing all instances of the variable type:

blah_t

to something else:

MyBlahType

Such a search and replace can be done in many ways. For one file it wouldn’t be unreasonable to run:

vim filename

then:

:%s/blah_t/MyBlahType/g
:wq

for multiple files, this isn’t the most convienent way (although you can do it with vim plus a command line for loop in a pinch using a vim command script if you really wanted to). An easier way is the following one liner:

perl -p -i -e 's/blah_t/MyBlahType/g' `cat r`

Let’s break this down. First is the `cat r` part. This presumes you are running in a unix shell where backquotes (not regular quotes like ”) mean “take the output of the back-quoted command and embed that in the new command”. This means the command above is equivalent to:

perl -p -i -e 's/blah_t/MyBlahType/g;' /vbs/engn/include/sqlbgbc_inlines.h /vbs/engn/include/sqlekrcb.h /vbs/engn/sqb/sqlbenvi.C

Next is the -i flag for the perl command. This specifies a suffix for a backup file. When no such file is specified (as here) then this means do an in-place modification of an existing file (something that’s particularily convienent if you are working with a version control system and if you have a recently checked out source file don’t have to worry as much about saving backups in case the search and replace goes wrong). If you wanted a backup, with suffix .bak, then replace -i with -i.bak (no spaces between -i and .bak).

The -e option says to treat the parameter as the entire perl program. By example, if you had the following small perl command in a file (say ./mySearchAndReplace):

$ cat ./mySearchAndReplace
s/blah_t/MyBlahType/g;

then the one liner above would also be equivalent to:

perl -p -i ./mySearchAndReplace /vbs/engn/include/sqlbgbc_inlines.h /vbs/engn/include/sqlekrcb.h /vbs/engn/sqb/sqlbenvi.C

The remaining worker option in the perl comand is the -p. This is really a convienence option and says to “wrap” the entire command (be that in a file or via -e) in a loop that processes standard input and outputs the results. You could do the same thing explicitly like so:

$ cat ./mySearchAndReplaceFilter
while (<>) # all lines from stdin
{
   s/blah_t/MyBlahType/g;
}

A command or script, such as sed, that takes all input from stdin and provides an altered stdout, is called a filter. In perl while (<$filehandle>) is the syntax to process all lines in an opened file, and nothing means the current default file (usually stdin). So a final decoding of the one liner is a command like:

perl -i ./mySearchAndReplaceFilter /vbs/engn/include/sqlbgbc_inlines.h /vbs/engn/include/sqlekrcb.h /vbs/engn/sqb/sqlbenvi.C

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

Bivector form of quantum angular momentum operator, the Coriolis term

Posted by peeterjoot on July 28, 2009

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

In the previous factorization of the Laplacian, a projection of the gradient along a constant direction vector \mathbf{a} we found

\begin{aligned}\boldsymbol{\nabla}^2 &=(\hat{\mathbf{a}} \cdot \boldsymbol{\nabla})^2 - (\hat{\mathbf{a}} \wedge \boldsymbol{\nabla})^2 \\  \end{aligned}

The vector \mathbf{a} was arbitrary, and just needed to be constant with respect to the factorization operations. The transition to non-constant vectors was largely guesswork and was in fact wrong. This guess was that we had

\begin{aligned}\boldsymbol{\nabla}^2 &= \frac{\partial^2 }{\partial r^2} - \frac{1}{{\mathbf{x}^2}} (\mathbf{x} \wedge \boldsymbol{\nabla})^2  \end{aligned} \quad\quad\quad(2)

The radial factorization of the gradient relied on the direction vector \mathbf{a} being constant. If we evaluate (2), then there should be a non-zero remainder compared to the Laplacian. Evaluation by coordinate expansion is one way to verify this, and should produce the difference. Let’s do this in two parts, starting with (x \wedge \nabla)^2. Summation will be implied by mixed indexes, and for generality a general basis and associated reciprocal frame will be used.

\begin{aligned}(x \wedge \nabla)^2 f &=((x^\mu \gamma_\mu) \wedge (\gamma_\nu \partial^\nu)) \cdot ((x_\alpha \gamma^\alpha) \wedge (\gamma^\beta \partial_\beta)) \\ &=(\gamma_\mu \wedge \gamma_\nu) \cdot (\gamma^\alpha \wedge \gamma^\beta) x^\mu \partial^\nu (x_\alpha \partial_\beta) f \\ &=({\delta_\mu}^\beta {\delta_\nu}^\alpha -{\delta_\mu}^\alpha {\delta_\nu}^\beta) x^\mu \partial^\nu (x_\alpha \partial_\beta) f \\ &=x^\mu \partial^\nu ((x_\nu \partial_\mu) - x_\mu \partial_\nu) f \\ &=x^\mu (\partial^\nu x_\nu) \partial_\mu f - x^\mu (\partial^\nu x_\mu) \partial_\nu f \\ &+x^\mu x_\nu \partial^\nu \partial_\mu f - x^\mu x_\mu \partial^\nu \partial_\nu f \\ &=(n-1) x \cdot \nabla f +x^\mu x_\nu \partial^\nu \partial_\mu f - x^2 \nabla^2 f \\  \end{aligned}

For the dot product we have

\begin{aligned}(x \cdot \nabla)^2 f &=x^\mu \partial_\mu( x^\nu \partial_\nu ) f \\ &=x^\mu (\partial_\mu x^\nu) \partial_\nu  f + x^\mu x^\nu \partial_\mu \partial_\nu f \\ &=x^\mu \partial_\mu f + x^\mu x_\nu \partial^\nu \partial_\mu f \\ &=x \cdot \nabla f + x^\mu x_\nu \partial^\nu \partial_\mu f \\  \end{aligned}

So, forming the difference we have

\begin{aligned}(x \cdot \nabla)^2 f - (x \wedge \nabla)^2 f &=-(n - 2) x \cdot \nabla f + x^2 \nabla^2 f \\  \end{aligned}

Or

\begin{aligned}\nabla^2 &= \frac{1}{{x^2}} (x \cdot \nabla)^2 - \frac{1}{{x^2}} (x \wedge \nabla)^2 + (n - 2) \frac{1}{{x}} \cdot \nabla  \end{aligned}

Going back to the quantum Hamiltonian we do still have the angular momentum operator as one of the distinct factors of the Laplacian. As operators we have something akin to the projection of the gradient onto the radial direction, as well as terms that project the gradient onto the tangential plane to the sphere at the radial point

\begin{aligned}-\frac{\hbar^2}{2m} \boldsymbol{\nabla}^2 + V&=-\frac{\hbar^2}{2m} \left( \frac{1}{{\mathbf{x}^2}} (\mathbf{x} \cdot \boldsymbol{\nabla})^2 - \frac{1}{{\mathbf{x}^2}} (\mathbf{x} \wedge \boldsymbol{\nabla})^2 + \frac{1}{{\mathbf{x}}} \cdot \boldsymbol{\nabla} \right) + V \end{aligned}

Posted in Math and Physics Learning. | Tagged: , , , | Leave a Comment »

Bivector form of quantum angular momentum operator

Posted by peeterjoot on July 27, 2009

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

Spatial bivector representation of the angular momentum operator.

Reading ([1]) on the angular momentum operator, the form of the operator is suggested by analogy where components of \mathbf{x} \times \mathbf{p} with
the position representation \mathbf{p} \sim -i \hbar \boldsymbol{\nabla} used to expand the coordinate representation of the operator.

The result is the following coordinate representation of the operator

\begin{aligned}L_1 &= -i \hbar( x_2 \partial_3 - x_3 \partial_2 ) \\ L_2 &= -i \hbar( x_3 \partial_1 - x_1 \partial_3 ) \\ L_3 &= -i \hbar( x_1 \partial_2 - x_2 \partial_1 ) \\  \end{aligned}

It is interesting to put these in vector form, and then employ the freedom to use for i = \sigma_1 \sigma_2 \sigma_3 the spatial pseudoscalar.

\begin{aligned}\mathbf{L} &= -\sigma_1 (\sigma_1 \sigma_2 \sigma_3) \hbar( x_2 \partial_3 - x_3 \partial_2 ) -\sigma_2 (\sigma_2 \sigma_3 \sigma_1) \hbar( x_3 \partial_1 - x_1 \partial_3 ) -\sigma_3 (\sigma_3 \sigma_1 \sigma_2) \hbar( x_1 \partial_2 - x_2 \partial_1 ) \\ &= -\sigma_2 \sigma_3 \hbar( x_2 \partial_3 - x_3 \partial_2 ) -\sigma_3 \sigma_1 \hbar( x_3 \partial_1 - x_1 \partial_3 ) -\sigma_1 \sigma_2 \hbar( x_1 \partial_2 - x_2 \partial_1 ) \\ &=-\hbar ( \sigma_1 x_1 +\sigma_2 x_2 +\sigma_3 x_3 ) \wedge ( \sigma_1 \partial_1 +\sigma_2 \partial_2 +\sigma_3 \partial_3 ) \\  \end{aligned}

The choice to use the pseudoscalar for this imaginary seems a logical one and the end result is a pure bivector representation of angular momentum operator

\begin{aligned}\mathbf{L} &= - \hbar \mathbf{x} \wedge \boldsymbol{\nabla} \end{aligned} \quad\quad\quad(1)

The choice to represent angular momentum as a bivector \mathbf{x} \wedge \mathbf{p} is also natural in classical mechanics (encoding the orientation of the plane and the magnitude of the momentum in the bivector), although its dual form the axial vector \mathbf{x} \times \mathbf{p} is more common, at least in introductory mechanics. Observe that there is no longer any explicit imaginary in (1), since the bivector itself has an implicit complex structure.

Factoring the gradient and Laplacian.

The form of (1) suggests a more direct way to extract the angular momentum operator from the Hamiltonian (i.e. from the Laplacian). Bohm uses the spherical polar representation of the Laplacian as the starting point. Instead let’s project the gradient itself in a specific constant direction \mathbf{a}, much as we can do to find the polar form angular velocity and acceleration components.

Write

\begin{aligned}\boldsymbol{\nabla} &=\frac{1}{{\mathbf{a}}} \mathbf{a} \boldsymbol{\nabla} \\ &=\frac{1}{{\mathbf{a}}} (\mathbf{a} \cdot \boldsymbol{\nabla} + \mathbf{a} \wedge \boldsymbol{\nabla}) \\  \end{aligned}

Or

\begin{aligned}\boldsymbol{\nabla} &=\boldsymbol{\nabla} \mathbf{a} \frac{1}{{\mathbf{a}}} \\ &=(\boldsymbol{\nabla} \cdot \mathbf{a} + \boldsymbol{\nabla} \wedge \mathbf{a}) \frac{1}{{\mathbf{a}}} \\ &=(\mathbf{a} \cdot \boldsymbol{\nabla} - \mathbf{a} \wedge \boldsymbol{\nabla}) \frac{1}{{\mathbf{a}}} \\  \end{aligned}

The Laplacian is therefore

\begin{aligned}\boldsymbol{\nabla}^2 &=\left\langle{{ \boldsymbol{\nabla}^2 }}\right\rangle \\ &=\left\langle{{ (\mathbf{a} \cdot \boldsymbol{\nabla} - \mathbf{a} \wedge \boldsymbol{\nabla}) \frac{1}{{\mathbf{a}}} \frac{1}{{\mathbf{a}}} (\mathbf{a} \cdot \boldsymbol{\nabla} + \mathbf{a} \wedge \boldsymbol{\nabla}) }}\right\rangle \\ &=\frac{1}{{\mathbf{a}^2}} \left\langle{{ (\mathbf{a} \cdot \boldsymbol{\nabla} - \mathbf{a} \wedge \boldsymbol{\nabla}) (\mathbf{a} \cdot \boldsymbol{\nabla} + \mathbf{a} \wedge \boldsymbol{\nabla}) }}\right\rangle \\ &=\frac{1}{{\mathbf{a}^2}} ((\mathbf{a} \cdot \boldsymbol{\nabla})^2 - (\mathbf{a} \wedge \boldsymbol{\nabla})^2 ) \\  \end{aligned}

So we have for the Laplacian a representation in terms of projection and rejection components

\boldsymbol{\nabla}^2 = (\hat{\mathbf{a}} \cdot \boldsymbol{\nabla})^2 - \frac{1}{\mathbf{a}^2} (\mathbf{a} \wedge \boldsymbol{\nabla})^2

The vector \mathbf{a} was arbitrary, and just needed to be constant with respect to the factorization operations. Setting \mathbf{a} = \mathbf{x}, the radial position from the origin, we have

\begin{aligned}\boldsymbol{\nabla}^2 &= \frac{\partial^2 }{\partial r^2} - \frac{1}{\mathbf{x}^2} (\mathbf{x} \wedge \boldsymbol{\nabla})^2  \end{aligned}

So in polar form the bivector form of the angular momentum operator is quite evident, just by application of projection of the gradient onto the radial direction and the tangential plane to the sphere at the radial point

\begin{aligned}-\frac{\hbar^2}{2m} \boldsymbol{\nabla}^2 + V&=-\frac{\hbar^2}{2m} \frac{\partial^2 }{\partial r^2} + \frac{\hbar^2}{2m \mathbf{x}^2} (\mathbf{x} \wedge \boldsymbol{\nabla})^2 + V \end{aligned}

References

[1] D. Bohm. Quantum Theory. Courier Dover Publications, 1989.

Posted in Math and Physics Learning. | Tagged: , , , | Leave a Comment »

free textbook on tensor calculus.

Posted by peeterjoot on July 24, 2009

Looks like a good one here to cover foundations for a study of GR http://www.math.odu.edu/~jhh/counter2.html. A free version is available to whet one’s appetite for a purchase, and even with only 80% of the content that free one concatonates to 373 pages!

Posted in Incoherent ramblings | Leave a Comment »

4D divergence theorem, continued.

Posted by peeterjoot on July 23, 2009

Obsolete with potential errors.

This post may be in error.  I wrote this before understanding that the gradient used in Stokes Theorem must be projected onto the tangent space of the parameterized surface, as detailed in Alan MacDonald’s Vector and Geometric Calculus.

See the post ‘stokes theorem in geometric algebra‘ [PDF], where this topic has been revisited with this in mind.

Original Post:

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

The basic idea of using duality to express the 4D divergence integral as a stokes boundary surface integral has been explored. Lets consider this in more detail picking a specific parametrization, namely rectangular four vector coordinates. For the volume element write

\begin{aligned}d^4 x &= ( \gamma_0 dx^0 ) \wedge ( \gamma_1 dx^1 ) \wedge ( \gamma_2 dx^2 ) \wedge ( \gamma_3 dx^3 ) \\ &= \gamma_0 \gamma_1 \gamma_2 \gamma_3 dx^0 dx^1 dx^2 dx^3 \\ &= i dx^0 dx^1 dx^2 dx^3 \\ \end{aligned}

As seen previously (but not separately), the divergence can be expressed as the dual of the curl

\begin{aligned}\nabla \cdot f&=\left\langle{{ \nabla f }}\right\rangle \\ &=-\left\langle{{ \nabla i (\underbrace{i f}_{\text{grade 3}}) }}\right\rangle \\ &=\left\langle{{ i \nabla (i f) }}\right\rangle \\ &=\left\langle{{ i ( \underbrace{\nabla \cdot (i f)}_{\text{grade 2}} + \underbrace{\nabla \wedge (i f)}_{\text{grade 4}} ) }}\right\rangle \\ &=i (\nabla \wedge (i f)) \\ \end{aligned}

So we have \nabla \wedge (i f) = -i (\nabla \cdot f). Putting things together, and writing i f = -f i we have

\begin{aligned}\int (\nabla \wedge (i f)) \cdot d^4 x&= \int (\nabla \cdot f) dx^0 dx^1 dx^2 dx^3 \\ &=\int dx^0 \partial_0 (f i) \cdot \gamma_{123} dx^1 dx^2 dx^3 \\ &-\int dx^1 \partial_1 (f i) \cdot \gamma_{023} dx^0 dx^2 dx^3 \\ &+\int dx^2 \partial_2 (f i) \cdot \gamma_{013} dx^0 dx^1 dx^3 \\ &-\int dx^3 \partial_3 (f i) \cdot \gamma_{012} dx^0 dx^1 dx^2 \\ \end{aligned}

It is straightforward to reduce each of these dot products. For example

\begin{aligned}\partial_2 (f i) \cdot \gamma_{013}&=\left\langle{{ \partial_2 f \gamma_{0123013} }}\right\rangle \\ &=-\left\langle{{ \partial_2 f \gamma_{2} }}\right\rangle \\ &=- \gamma_2 \partial_2 \cdot f \\ &=\gamma^2 \partial_2 \cdot f \end{aligned}

The rest proceed the same and rather anticlimactically we end up coming full circle

\begin{aligned}\int (\nabla \cdot f) dx^0 dx^1 dx^2 dx^3 &=\int dx^0 \gamma^0 \partial_0 \cdot f dx^1 dx^2 dx^3 \\ &+\int dx^1 \gamma^1 \partial_1 \cdot f dx^0 dx^2 dx^3 \\ &+\int dx^2 \gamma^2 \partial_2 \cdot f dx^0 dx^1 dx^3 \\ &+\int dx^3 \gamma^3 \partial_3 \cdot f dx^0 dx^1 dx^2 \\ \end{aligned}

This is however nothing more than the definition of the divergence itself and no need to resort to Stokes theorem is required. However, if we are integrating over a rectangle and perform each of the four integrals, we have (with c=1) from the dual Stokes equation the perhaps less obvious result

\begin{aligned}\int \partial_\mu f^\mu dt dx dy dz&=\int (f^0(t_1) - f^0(t_0)) dx dy dz \\ &+\int (f^1(x_1) - f^1(x_0)) dt dy dz \\ &+\int (f^2(y_1) - f^2(y_0)) dt dx dz \\ &+\int (f^3(z_1) - f^3(z_0)) dt dx dy \\ \end{aligned}

When stated this way one sees that this could have just as easily have followed directly from the left hand side. What’s the point then of the divergence theorem or Stokes theorem? I think that the value must really be the fact that the Stokes formulation naturally builds the volume element in a fashion independent of any specific parametrization. Here in rectangular coordinates the result seems obvious, but would the equivalent result seem obvious if non-rectangular spacetime coordinates were employed? Probably not.

Posted in Math and Physics Learning. | Tagged: , , , | Leave a Comment »

the most basic vi trick. exiting the damn thing.

Posted by peeterjoot on July 23, 2009

Although I now rate myself as a guru level vi user, there was a time that I totally hated the vi editor. Back in university if you tried to run the newsreader (trn in those days) if you hadn’t configured for a “usable” editor, vi would be invoked and then you were stuck.

So, … if you don’t want to use vi, and end up using it by mistake, how to exit? The following is promising looking, but doesn’t actually work:

~
~
~
:!@$!@^! shit, how the hell do you exit this damn thing

Here’s the real way.

Step 1: If you are in edit mode (you have on purpose or accidentally hit the ‘i’ character) you’ll need to hit the Escape character on your keyboard. If you don’t know if you are in edit mode or not you can hit the Esc character. You can hit it five times if you like, once you are out of edit mode, you’ll stay there.

Step 2: type ‘:’ (the colon character), then wq, or q, or q! or wq! Example output at the bottom of the vi screen will look something like:

~
~
~
:wq!

This last one means write and quit, and a really mean it, even if I have multiple files being edited. Plain old “:w” is just write, “:q” is quit, and “:q!” is “quit damnit, yes I really mean it”

While my vi hating days are gone, the transition from vi hating to loving requires one first baby step: being able to exit the damn editor. Eventually, if like me, you are forced to work on multi platform Unix development where the only editor you can depend on is vi, taking further steps away from vi hating may be possible.

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

Stokes theorem in Geometric Algebra formalism.

Posted by peeterjoot on July 22, 2009

Obsolete with potential errors.

This post may be in error.  I wrote this before understanding that the gradient used in Stokes Theorem must be projected onto the tangent space of the parameterized surface, as detailed in Alan MacDonald’s Vector and Geometric Calculus.

See the post ‘stokes theorem in geometric algebra‘ [PDF], where this topic has been revisited with this in mind.

Original Post:

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

Motivation

Relying on pictorial means and a brute force ugly comparison of left and right hand sides, a verification of Stokes theorem for the vector and bivector cases was performed ([1]). This was more of a confirmation than a derivation, and the technique fails the transition to the trivector case. The trivector case is of particular interest in electromagnetism since that and a duality transformation provides a four-vector divergence theorem.

The fact that the pictorial means of defining the boundary surface doesn’t work well in four vector space is not the only unsatisfactory aspect of the previous treatment. The fact that a coordinate expansion of the hypervolume element and hypersurface element was performed in the LHS and RHS comparisons was required is particularly ugly. It is a lot of work and essentially has to be undone on the opposing side of the equation. Comparing to previous attempts to come to terms with Stokes theorem in ([2]) and ([3]) this more recent attempt at least avoids the requirement for a tensor expansion of the vector or bivector. It should be possible to build on this and minimize the amount of coordinate expansion required and go directly from the volume integral to the expression of the boundary surface.

Do it.

Notation and Setup.

The desire is to relate the curl hypervolume integral to a hypersurface integral on the boundary

\begin{aligned}\int (\nabla \wedge F) \cdot d^k x = \int F \cdot d^{k-1} x\end{aligned} \hspace{\stretch{1}}(2.1)

In order to put meaning to this statement the volume and surface elements need to be properly defined. In order that this be a scalar equation, the object F in the integral is required to be of grade k-1, and k \le n where n is the dimension of the vector space that generates the object F.

Reciprocal frames.

As evident in equation (2.1) a metric is required to define the dot product. If an affine non-metric formulation
of Stokes theorem is possible it will not be attempted here. A reciprocal basis pair will be utilized, defined by

\begin{aligned}\gamma^\mu \cdot \gamma_\nu = {\delta^\mu}_\nu\end{aligned} \hspace{\stretch{1}}(2.2)

Both of the sets \{\gamma_\mu\} and \{\gamma^\mu\} are taken to span the space, but are not required to be orthogonal. The notation is consistent with the Dirac reciprocal basis, and there will not be anything in this treatment that prohibits the Minkowski metric signature required for such a relativistic space.

Vector decomposition in terms of coordinates follows by taking dot products. We write

\begin{aligned}x = x^\mu \gamma_\mu = x_\nu \gamma^\nu\end{aligned} \hspace{\stretch{1}}(2.3)

Gradient.

When working with a non-orthonormal basis, use of the reciprocal frame can be utilized to express the gradient.

\begin{aligned}\nabla \equiv \gamma^\mu \partial_\mu \equiv \sum_\mu \gamma^\mu \frac{\partial {}}{\partial {x^\mu}}\end{aligned} \hspace{\stretch{1}}(2.4)

This contains what may perhaps seem like an odd seeming mix of upper and lower indexes in this definition. This is how the gradient is defined in [4]. Although it is possible to accept this definition and work with it, this form can be justified by require of the gradient consistency with the the definition of directional derivative. A definition of the directional derivative that works for single and multivector functions, in \mathbb{R}^{3} and other more general spaces is

\begin{aligned}a \cdot \nabla F \equiv \lim_{\lambda \rightarrow 0} \frac{F(x + a\lambda) - F(x)}{\lambda} = {\left.\frac{\partial {F(x + a\lambda)}}{\partial {\lambda}} \right\vert}_{\lambda=0}\end{aligned} \hspace{\stretch{1}}(2.5)

Taylor expanding about \lambda=0 in terms of coordinates we have

\begin{aligned}{\left.\frac{\partial {F(x + a\lambda)}}{\partial {\lambda}} \right\vert}_{\lambda=0}&= a^\mu \frac{\partial {F}}{\partial {x^\mu}} \\ &= (a^\nu \gamma_\nu) \cdot (\gamma^\mu \partial_\mu) F \\ &= a \cdot \nabla F \quad\quad\quad\square\end{aligned}

The lower index representation of the vector coordinates could also have been used, so using the directional derivative to imply a definition of the gradient, we have an additional alternate representation of the gradient

\begin{aligned}\nabla \equiv \gamma_\mu \partial^\mu \equiv \sum_\mu \gamma_\mu \frac{\partial {}}{\partial {x_\mu}}\end{aligned} \hspace{\stretch{1}}(2.6)

Volume element

We define the hypervolume in terms of parametrized vector displacements x = x(a_1, a_2, ... a_k). For the vector x we can form a pseudoscalar for the subspace spanned by this parametrization by wedging the displacements in each of the directions defined by variation of the parameters. For m \in [1,k] let

\begin{aligned}dx_i = \frac{\partial {x}}{\partial {a_i}} da_i = \gamma_\mu \frac{\partial {x^\mu}}{\partial {a_i}} da_i,\end{aligned} \hspace{\stretch{1}}(2.7)

so the hypervolume element for the subspace in question is

\begin{aligned}d^k x \equiv dx_1 \wedge dx_2 \cdots dx_k\end{aligned} \hspace{\stretch{1}}(2.8)

This can be expanded explicitly in coordinates

\begin{aligned}d^k x &= da_1 da_2 \cdots da_k \left(\frac{\partial {x^{\mu_1}}}{\partial {a_1}} \frac{\partial {x^{\mu_2}}}{\partial {a_2}} \cdots\frac{\partial {x^{\mu_k}}}{\partial {a_k}} \right)( \gamma_{\mu_1} \wedge \gamma_{\mu_2} \wedge \cdots \wedge \gamma_{\mu_k} ) \\ \end{aligned}

Observe that when k is also the dimension of the space, we can employ a pseudoscalar I = \gamma_0 \gamma_1 \cdots \gamma_k and can specify our volume element in terms of the Jacobian determinant.

This is

\begin{aligned}d^k x =I da_1 da_2 \cdots da_k {\left\lvert{\frac{\partial {(x^1, x^2, \cdots, x^k)}}{\partial {(a_1, a_2, \cdots, a_k)}}}\right\rvert}\end{aligned} \hspace{\stretch{1}}(2.9)

However, we won’t have a requirement to express the Stokes result in terms of such Jacobians.

Expansion of the curl and volume element product

We are now prepared to go on to the meat of the issue. The first order of business is the expansion of the curl and volume element product

\begin{aligned}( \nabla \wedge F ) \cdot d^k x&=( \gamma^\mu \wedge \partial_\mu F ) \cdot d^k x \\ &=\left\langle{{ ( \gamma^\mu \wedge \partial_\mu F ) d^k x }}\right\rangle \\ \end{aligned}

The wedge product within the scalar grade selection operator can be expanded in symmetric or antisymmetric sums, but this is a grade dependent operation. For odd grade blades A (vector, trivector, …), and vector a we have for the dot and wedge product respectively

\begin{aligned}a \wedge A = \frac{1}{{2}} (a A - A a) \\ a \cdot A = \frac{1}{{2}} (a A + A a)\end{aligned}

Similarly for even grade blades we have

\begin{aligned}a \wedge A = \frac{1}{{2}} (a A + A a) \\ a \cdot A = \frac{1}{{2}} (a A - A a)\end{aligned}

First treating the odd grade case for F we have

\begin{aligned}( \nabla \wedge F ) \cdot d^k x&=\frac{1}{{2}} \left\langle{{ \gamma^\mu \partial_\mu F d^k x }}\right\rangle - \frac{1}{{2}} \left\langle{{ \partial_\mu F \gamma^\mu d^k x }}\right\rangle \\ \end{aligned}

Employing cyclic scalar reordering within the scalar product for the first term

\begin{aligned}\left\langle{{a b c}}\right\rangle = \left\langle{{b c a}}\right\rangle\end{aligned} \hspace{\stretch{1}}(2.10)

we have

\begin{aligned}( \nabla \wedge F ) \cdot d^k x&=\frac{1}{{2}} \left\langle{{ \partial_\mu F (d^k x \gamma^\mu - \gamma^\mu d^k x)}}\right\rangle \\ &=\frac{1}{{2}} \left\langle{{ \partial_\mu F (d^k x \cdot \gamma^\mu - \gamma^\mu d^k x)}}\right\rangle \\ &=\left\langle{{ \partial_\mu F (d^k x \cdot \gamma^\mu)}}\right\rangle \\ \end{aligned}

The end result is

\begin{aligned}( \nabla \wedge F ) \cdot d^k x &= \partial_\mu F \cdot (d^k x \cdot \gamma^\mu) \end{aligned} \hspace{\stretch{1}}(2.11)

For even grade F (and thus odd grade d^k x) it is straightforward to show that (2.11) also holds.

Expanding the volume dot product

We want to expand the volume integral dot product

\begin{aligned}d^k x \cdot \gamma^\mu\end{aligned} \hspace{\stretch{1}}(2.12)

Picking k = 4 will serve to illustrate the pattern, and the generalization (or degeneralization to lower grades) will be clear. We have

\begin{aligned}d^4 x \cdot \gamma^\mu&=( dx_1 \wedge dx_2 \wedge dx_3 \wedge dx_4 ) \cdot \gamma^\mu \\ &= ( dx_1 \wedge dx_2 \wedge dx_3 ) dx_4 \cdot \gamma^\mu \\ &-( dx_1 \wedge dx_2 \wedge dx_4 ) dx_3 \cdot \gamma^\mu \\ &+( dx_1 \wedge dx_3 \wedge dx_4 ) dx_2 \cdot \gamma^\mu \\ &-( dx_2 \wedge dx_3 \wedge dx_4 ) dx_1 \cdot \gamma^\mu \\ \end{aligned}

This avoids the requirement to do the entire Jacobian expansion of (2.9). The dot product of the differential displacement dx_m with \gamma^\mu can now be made explicit without as much mess.

\begin{aligned}dx_m \cdot \gamma^\mu &=da_m \frac{\partial {x^\nu}}{\partial {a_m}} \gamma_\nu \cdot \gamma^\mu \\ &=da_m \frac{\partial {x^\mu}}{\partial {a_m}} \\ \end{aligned}

We now have products of the form

\begin{aligned}\partial_\mu F da_m \frac{\partial {x^\mu}}{\partial {a_m}} &=da_m \frac{\partial {x^\mu}}{\partial {a_m}} \frac{\partial {F}}{\partial {x^\mu}} \\ &=da_m \frac{\partial {F}}{\partial {a_m}} \\ \end{aligned}

Now we see that the differential form of (2.11) for this k=4 example is reduced to

\begin{aligned}( \nabla \wedge F ) \cdot d^4 x &= da_4 \frac{\partial {F}}{\partial {a_4}} \cdot ( dx_1 \wedge dx_2 \wedge dx_3 ) \\ &- da_3 \frac{\partial {F}}{\partial {a_3}} \cdot ( dx_1 \wedge dx_2 \wedge dx_4 ) \\ &+ da_2 \frac{\partial {F}}{\partial {a_2}} \cdot ( dx_1 \wedge dx_3 \wedge dx_4 ) \\ &- da_1 \frac{\partial {F}}{\partial {a_1}} \cdot ( dx_2 \wedge dx_3 \wedge dx_4 ) \\ \end{aligned}

While 2.11 was a statement of Stokes theorem in this Geometric Algebra formulation, it was really incomplete without this explicit expansion of (\partial_\mu F) \cdot (d^k x \cdot \gamma^\mu). This expansion for the k=4 case serves to illustrate that we would write Stokes theorem as

\begin{aligned}\boxed{\int( \nabla \wedge F ) \cdot d^k x =\frac{1}{{(k-1)!}} \epsilon^{ r s \cdots t u } \int da_u \frac{\partial {F}}{\partial {a_{u}}} \cdot (dx_r \wedge dx_s \wedge \cdots \wedge dx_t)}\end{aligned} \hspace{\stretch{1}}(2.13)

Here the indexes have the range \{r, s, \cdots, t, u\} \in \{1, 2, \cdots k\}. This with the definitions 2.7, and 2.8 is really Stokes theorem in its full glory.

Observe that in this Geometric algebra form, the one forms dx_i = da_i {\partial {x}}/{\partial {a_i}}, i \in [1,k] are nothing more abstract that plain old vector differential elements. In the formalism of differential forms, this would be vectors, and (\nabla \wedge F) \cdot d^k x would be a k form. In a context where we are working with vectors, or blades already, the Geometric Algebra statement of the theorem avoids a requirement to translate to the language of forms.

With a statement of the general theorem complete, let’s return to our k=4 case where we can now integrate over each of the a_1, a_2, \cdots, a_k parameters. That is

\begin{aligned}\int ( \nabla \wedge F ) \cdot d^4 x &= \int (F(a_4(1)) - F(a_4(0))) \cdot ( dx_1 \wedge dx_2 \wedge dx_3 ) \\ &- \int (F(a_3(1)) - F(a_3(0))) \cdot ( dx_1 \wedge dx_2 \wedge dx_4 ) \\ &+ \int (F(a_2(1)) - F(a_2(0))) \cdot ( dx_1 \wedge dx_3 \wedge dx_4 ) \\ &- \int (F(a_1(1)) - F(a_1(0))) \cdot ( dx_2 \wedge dx_3 \wedge dx_4 ) \\ \end{aligned}

This is precisely Stokes theorem for the trivector case and makes the enumeration of the boundary surfaces explicit. As derived there was no requirement for an orthonormal basis, nor a Euclidean metric, nor a parametrization along the basis directions. The only requirement of the parametrization is that the associated volume element is non-trivial (i.e. none of dx_q \wedge dx_r = 0).

For completeness, note that our boundary surface and associated Stokes statement for the bivector and vector cases is, by inspection respectively

\begin{aligned}\int ( \nabla \wedge F ) \cdot d^3 x &= \int (F(a_3(1)) - F(a_3(0))) \cdot ( dx_1 \wedge dx_2 ) \\ &- \int (F(a_2(1)) - F(a_2(0))) \cdot ( dx_1 \wedge dx_3 ) \\ &+ \int (F(a_1(1)) - F(a_1(0))) \cdot ( dx_2 \wedge dx_3 ) \\ \end{aligned}

and

\begin{aligned}\int ( \nabla \wedge F ) \cdot d^2 x &= \int (F(a_2(1)) - F(a_2(0))) \cdot dx_1 \\ &- \int (F(a_1(1)) - F(a_1(0))) \cdot dx_2 \\ \end{aligned}

These three expansions can be summarized by the original single statement of (2.1), which repeating for reference, is

\begin{aligned}\int ( \nabla \wedge F ) \cdot d^k x = \int F \cdot d^{k-1} x \end{aligned}

Where it is implied that the blade F is evaluated on the boundaries and dotted with the associated hypersurface boundary element. However, having expanded this we now have an explicit statement of exactly what that surface element is now for any desired parametrization.

Duality relations and special cases.

Some special (and more recognizable) cases of (2.1) are possible considering specific grades of F, and in some cases employing duality relations.

curl surface integral

One important case is the \mathbb{R}^{3} vector result, which can be expressed in terms of the cross product.

Write \hat{\mathbf{n}} d^2 x = -i dA. Then we have

\begin{aligned}( \boldsymbol{\nabla} \wedge \mathbf{f} ) \cdot d^2 x&=\left\langle{{ i (\boldsymbol{\nabla} \times \mathbf{f}) (- \hat{\mathbf{n}} i dA) }}\right\rangle \\ &=(\boldsymbol{\nabla} \times \mathbf{f}) \cdot \hat{\mathbf{n}} dA\end{aligned}

This recovers the familiar cross product form of Stokes law.

\begin{aligned}\int (\boldsymbol{\nabla} \times \mathbf{f}) \cdot \hat{\mathbf{n}} dA = \oint \mathbf{f} \cdot d\mathbf{x}\end{aligned} \hspace{\stretch{1}}(3.14)

3D divergence theorem

Duality applied to the bivector Stokes result provides the divergence theorem in \mathbb{R}^{3}. For bivector B, let iB = \mathbf{f}, d^3 x = i dV, and d^2 x = i \hat{\mathbf{n}} dA. We then have

\begin{aligned}( \boldsymbol{\nabla} \wedge B ) \cdot d^3 x&=\left\langle{{ ( \boldsymbol{\nabla} \wedge B ) \cdot d^3 x }}\right\rangle \\ &=\frac{1}{{2}} \left\langle{{ ( \boldsymbol{\nabla} B + B \boldsymbol{\nabla} ) i dV }}\right\rangle \\ &=\boldsymbol{\nabla} \cdot \mathbf{f} dV \\ \end{aligned}

Similarly

\begin{aligned}B \cdot d^2 x&=\left\langle{{ -i\mathbf{f} i \hat{\mathbf{n}} dA}}\right\rangle \\ &=(\mathbf{f} \cdot \hat{\mathbf{n}}) dA \\ \end{aligned}

This recovers the \mathbb{R}^{3} divergence equation

\begin{aligned}\int \boldsymbol{\nabla} \cdot \mathbf{f} dV = \int (\mathbf{f} \cdot \hat{\mathbf{n}}) dA\end{aligned} \hspace{\stretch{1}}(3.15)

4D divergence theorem

How about the four dimensional spacetime divergence? Write, express a trivector as a dual four-vector T = if, and the four volume element d^4 x = i dQ. This gives

\begin{aligned}(\nabla \wedge T) \cdot d^4 x&=\frac{1}{{2}} \left\langle{{ (\nabla T - T \nabla) i }}\right\rangle dQ \\ &=\frac{1}{{2}} \left\langle{{ (\nabla i f - if \nabla) i }}\right\rangle dQ \\ &=\frac{1}{2} \left\langle{{ (\nabla f + f \nabla) }}\right\rangle dQ \\ &=(\nabla \cdot f) dQ\end{aligned}

For the boundary volume integral write d^3 x = n i dV, for

\begin{aligned}T \cdot d^3 x &= \left\langle{{ (if) ( n i ) }}\right\rangle dV \\ &= \left\langle{{ f n }}\right\rangle dV \\ &= (f \cdot n) dV\end{aligned}

So we have

\begin{aligned}\int \partial_\mu f^\mu dQ = \int f^\nu n_\nu dV\end{aligned}

the orientation of the fourspace volume element and the boundary normal is defined in terms of the parametrization, the duality relations and our explicit expansion of the 4D stokes boundary integral above.

4D divergence theorem, continued.

The basic idea of using duality to express the 4D divergence integral as a stokes boundary surface integral has been explored. Lets consider this in more detail picking a specific parametrization, namely rectangular four vector coordinates. For the volume element write

\begin{aligned}d^4 x &= ( \gamma_0 dx^0 ) \wedge ( \gamma_1 dx^1 ) \wedge ( \gamma_2 dx^2 ) \wedge ( \gamma_3 dx^3 ) \\ &= \gamma_0 \gamma_1 \gamma_2 \gamma_3 dx^0 dx^1 dx^2 dx^3 \\ &= i dx^0 dx^1 dx^2 dx^3 \\ \end{aligned}

As seen previously (but not separately), the divergence can be expressed as the dual of the curl

\begin{aligned}\nabla \cdot f&=\left\langle{{ \nabla f }}\right\rangle \\ &=-\left\langle{{ \nabla i (\underbrace{i f}_{\text{grade 3}}) }}\right\rangle \\ &=\left\langle{{ i \nabla (i f) }}\right\rangle \\ &=\left\langle{{ i ( \underbrace{\nabla \cdot (i f)}_{\text{grade 2}} + \underbrace{\nabla \wedge (i f)}_{\text{grade 4}} ) }}\right\rangle \\ &=i (\nabla \wedge (i f)) \\ \end{aligned}

So we have \nabla \wedge (i f) = -i (\nabla \cdot f). Putting things together, and writing i f = -f i we have

\begin{aligned}\int (\nabla \wedge (i f)) \cdot d^4 x&= \int (\nabla \cdot f) dx^0 dx^1 dx^2 dx^3 \\ &=\int dx^0 \partial_0 (f i) \cdot \gamma_{123} dx^1 dx^2 dx^3 \\ &-\int dx^1 \partial_1 (f i) \cdot \gamma_{023} dx^0 dx^2 dx^3 \\ &+\int dx^2 \partial_2 (f i) \cdot \gamma_{013} dx^0 dx^1 dx^3 \\ &-\int dx^3 \partial_3 (f i) \cdot \gamma_{012} dx^0 dx^1 dx^2 \\ \end{aligned}

It is straightforward to reduce each of these dot products. For example

\begin{aligned}\partial_2 (f i) \cdot \gamma_{013}&=\left\langle{{ \partial_2 f \gamma_{0123013} }}\right\rangle \\ &=-\left\langle{{ \partial_2 f \gamma_{2} }}\right\rangle \\ &=- \gamma_2 \partial_2 \cdot f \\ &=\gamma^2 \partial_2 \cdot f \end{aligned}

The rest proceed the same and rather anticlimactically we end up coming full circle

\begin{aligned}\int (\nabla \cdot f) dx^0 dx^1 dx^2 dx^3 &=\int dx^0 \gamma^0 \partial_0 \cdot f dx^1 dx^2 dx^3 \\ &+\int dx^1 \gamma^1 \partial_1 \cdot f dx^0 dx^2 dx^3 \\ &+\int dx^2 \gamma^2 \partial_2 \cdot f dx^0 dx^1 dx^3 \\ &+\int dx^3 \gamma^3 \partial_3 \cdot f dx^0 dx^1 dx^2 \\ \end{aligned}

This is however nothing more than the definition of the divergence itself and no need to resort to Stokes theorem is required. However, if we are integrating over a rectangle and perform each of the four integrals, we have (with c=1) from the dual Stokes equation the perhaps less obvious result

\begin{aligned}\int \partial_\mu f^\mu dt dx dy dz&=\int (f^0(t_1) - f^0(t_0)) dx dy dz \\ &+\int (f^1(x_1) - f^1(x_0)) dt dy dz \\ &+\int (f^2(y_1) - f^2(y_0)) dt dx dz \\ &+\int (f^3(z_1) - f^3(z_0)) dt dx dy \\ \end{aligned}

When stated this way one sees that this could have just as easily have followed directly from the left hand side. What’s the point then of the divergence theorem or Stokes theorem? I think that the value must really be the fact that the Stokes formulation naturally builds the volume element in a fashion independent of any specific parametrization. Here in rectangular coordinates the result seems obvious, but would the equivalent result seem obvious if non-rectangular spacetime coordinates were employed? Probably not.

References

[1] Peeter Joot. Stokes theorem applied to vector and bivector fields [online]. http://sites.google.com/site/peeterjoot/math2009/stokesGradeTwo.pdf.

[2] Peeter Joot. Stokes law in wedge product form [online]. http://sites.google.com/site/peeterjoot/geometric-algebra/vector_integral_relations.pdf.

[3] Peeter Joot. Stokes Law revisited with algebraic enumeration of boundary [online]. http://sites.google.com/site/peeterjoot/geometric-algebra/stokes_revisited.pdf.

[4] C. Doran and A.N. Lasenby. Geometric algebra for physicists. Cambridge University Press New York, Cambridge, UK, 1st edition, 2003.

Posted in Math and Physics Learning. | Tagged: , , , , , , , , , , | 1 Comment »

vim: swap two patterns

Posted by peeterjoot on July 22, 2009

Suppose you want to invert something like the following assignment

pageName->name1 = fakeBPD->pageKey.pageID.pkPageNum;
pageName->name2 = fakeBPD->pageKey.pageID.pkPoolID;
pageName->name3 = fakeBPD->pageKey.pageID.pkObjectID;
pageName->name4 = fakeBPD->pageKey.pageID.pkObjectType;

to produce:

fakeBPD->pageKey.pageID.pkPageNum = pageName->name1;
fakeBPD->pageKey.pageID.pkPoolID = pageName->name2;
fakeBPD->pageKey.pageID.pkObjectID = pageName->name3;
fakeBPD->pageKey.pageID.pkObjectType = pageName->name4;

positioning on the first line, this requires nothing more than:

,+3 s/\(.*\) = \(.*\);/\2 = \1;/

Lets break this down. The first part :,+3 specifies a range of lines. For example

:1,3 s/something/else/

this would replace something with else on lines 1-3. If the first line number is left off, the current line is implied, and as above the end line number can be a computed expression relative to the current line (i.e. I did three additional lines on top of the current line).

The line numbers themselves can be patterns. For example:

:,/^}/ s/something/else/

would make the substuition something -> else from the current line to the line that starts with } (^ matches to the beginning of the line). Now, how about the original seach and replace. There a regular expression capture was used. The match pattern was essentially:

/.* = .*;/

but we want to put the two interesting bits in regular expression variables (back references) that can be referred to in the replacement expression. In vim the back references go like \1, \2, …. Different regular expression engines do this differently, and in perl you’d use $1, $2 for the back references, and to generate them just /(.*) = (.*);/ instead of \(.*\).

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

A vim -q Plus grep -n. An editor trick everybody should know.

Posted by peeterjoot on July 20, 2009

If you use vi as your editor (and by vi I assume vi == vim), then you want to know about the vim -q option, and grep -n to go with it.

This can be used to navigate through code (or other files) looking at matches to patterns of interest. Suppose you want to look at calls of strchr() that match some pattern. One way to do this is to find the subset of the files that are of interest. Say:

$ grep strchr.*ode sqle*ca*C
sqlecatd.C:                              sres = strchr(SQLZ_IDENT, (Uint8)nodename[i]);
sqlecatn.C:                  if ((sres = strchr(SQLZ_DBNAME, (Uint8)mode[0])) != NULL)
sqlecatn.C:                        sres = strchr(SQLZ_IDENT_AID, (Uint8)mode[i]);

and edit all those files, searching again for the pattern of interest in each file. If there aren’t many such matches, your job is easy and can be done manually. Suppose however that there’s 20 such matches, and 3 or 4 are of interest for editing, but you won’t know till you’ve seen them with a bit more context. What’s an easy way to go from one to the next? The trick is grep -n plus vim. Example:

$ grep -n strchr.*ode sqle*ca*C | tee grep.out
sqlecatd.C:710:                              sres = strchr(SQLZ_IDENT, (Uint8)nodename[i]);
sqlecatn.C:505:                  if ((sres = strchr(SQLZ_DBNAME, (Uint8)mode[0])) != NULL)
sqlecatn.C:518:                        sres = strchr(SQLZ_IDENT_AID, (Uint8)mode[i]);

$ vim -q grep.out

vim will bring you right to line 710 of sqlecatd.C in this case. To go to the next pattern, which will be in this case also in the next file, use the vim command

:cn

You can move backwards with :cN, and see where you are and the associated pattern with :cc

vim -q understands a lot of common filename/linenumber formats (and can probably be taught more but I haven’t tried that). Of particular utility is compile error output. Redirect your compilation error output (from gcc/g++ for example) to a file, and when that file is stripped down to just the error lines, you can navigate from error to error with ease (until you muck up the line numbers too much).

A small note. If you are grepping only one file, then the grep -n output won’t have the filename and vim -q will get confused. Example:

grep -n strchr.*ode sqlecatn.C
505:                  if ((sres = strchr(SQLZ_DBNAME, (Uint8)mode[0])) != NULL)
518:                        sres = strchr(SQLZ_IDENT_AID, (Uint8)mode[i]);

Here just include a filename that doesn’t exist in the grep command line string

grep -n strchr.*ode sqlecatn.C blah 2>/dev/null
sqlecatn.C:505:                  if ((sres = strchr(SQLZ_DBNAME, (Uint8)mode[0])) != NULL)
sqlecatn.C:518:                        sres = strchr(SQLZ_IDENT_AID, (Uint8)mode[i]);

I’m assuming here that you don’t have a file called blah in the current directory. The result is something that vim -q will still be happy about.

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