In [1]:
from IPython.display import Math, display
def displayWithTitle(multivector, title):
display(Math(title + '=' + multivector._repr_latex_()))
def CheckProperties(i,j,k):
ilabel = i.texLabel
jlabel = j.texLabel
klabel = k.texLabel
displayWithTitle(i, title=ilabel)
displayWithTitle(j, title=jlabel)
displayWithTitle(k, title=klabel)
displayWithTitle((i*i), title=ilabel+'^2')
displayWithTitle((j*j), title=jlabel+'^2')
displayWithTitle((k*k), title=klabel+'^2')
displayWithTitle((i*j), title=ilabel + jlabel)
displayWithTitle((j*i), title=jlabel + ilabel)
displayWithTitle((j*k), title=jlabel + klabel)
displayWithTitle((k*j), title=klabel + jlabel)
displayWithTitle((k*i), title=klabel + ilabel)
displayWithTitle((i*k), title=ilabel + klabel)
displayWithTitle((i*j*k), title=ilabel + jlabel + klabel)
In [2]:
from sympy.matrices import *
from galgebra.ga import Ga
from galgebra.printer import *
In [3]:
from sympy import *
variables = (x, y, z, w) = symbols('x y z w', real=True)
print(variables)
In [4]:
metric=[ 1
,1
,1
,1]
myBasis='e_1 e_2 e_3 e_4'
sp4d = Ga(myBasis, g=metric, coords=variables,norm=True)
(e_1, e_2, e_3, e_4) = sp4d.mv()
http://en.wikipedia.org/wiki/Quaternion https://en.wikipedia.org/wiki/Pauli_matrices
In [5]:
sigma_1w=e_2*e_3
sigma_2w=e_3*e_1
sigma_3w=-e_1*e_2
sigma_1w.texLabel='\\sigma_{1w}'
sigma_2w.texLabel='\\sigma_{2w}'
sigma_3w.texLabel='\\sigma_{3w}'
display(Math('(1,'+sigma_1w.texLabel+','+sigma_2w.texLabel+','+sigma_3w.texLabel+')'))
CheckProperties(sigma_1w,sigma_2w,sigma_3w)
In [6]:
sigma_1x=e_2*e_3
sigma_2x=e_3*e_4
sigma_3x=-e_4*e_2
sigma_1x.texLabel='\\sigma_{1x}'
sigma_2x.texLabel='\\sigma_{2x}'
sigma_3x.texLabel='\\sigma_{3x}'
display(Math('(1,'+sigma_1x.texLabel+','+sigma_2x.texLabel+','+sigma_3x.texLabel+')'))
CheckProperties(sigma_1x,sigma_2x,sigma_3x)
In [7]:
sigma_1y=e_1*e_3
sigma_2y=e_3*e_4
sigma_3y=-e_4*e_1
sigma_1y.texLabel='\\sigma_{1y}'
sigma_2y.texLabel='\\sigma_{2y}'
sigma_3y.texLabel='\\sigma_{3y}'
display(Math('(1,'+sigma_1y.texLabel+','+sigma_2y.texLabel+','+sigma_3y.texLabel+')'))
CheckProperties(sigma_1y,sigma_2y,sigma_3y)
In [8]:
sigma_1z=e_1*e_2
sigma_2z=e_2*e_4
sigma_3z=-e_4*e_1
sigma_1z.texLabel='\\sigma_{1z}'
sigma_2z.texLabel='\\sigma_{2z}'
sigma_3z.texLabel='\\sigma_{3z}'
display(Math('(1,'+sigma_1z.texLabel+','+sigma_2z.texLabel+','+sigma_3z.texLabel+')'))
CheckProperties(sigma_1z,sigma_2z,sigma_3z)
In [9]:
gamma_4=e_1*e_2*e_3
gamma_1=e_4*e_2*e_3
gamma_2=e_1*e_4*e_3
gamma_3=e_1*e_2*e_4
displayWithTitle(gamma_4,title='\\gamma_4')
displayWithTitle(gamma_4*gamma_4,title='\\gamma_4^2')
displayWithTitle(gamma_1,title='\\gamma_1')
displayWithTitle(gamma_1*gamma_1,title='\\gamma_1^2')
displayWithTitle(gamma_2,title='\\gamma_2')
displayWithTitle(gamma_2*gamma_2,title='\\gamma_2^2')
displayWithTitle(gamma_3,title='\\gamma_3')
displayWithTitle(gamma_3*gamma_3,title='\\gamma_3^2')
In [10]:
m, q = symbols('m q', real=True)
rquat = [sigma_1w, sigma_2w, sigma_3w]
In [11]:
B_x, B_y, B_z = symbols('B_x B_y B_z', real=True)
Bv =[B_x, B_y, B_z]
B = S(0)
for (dim, var) in zip(Bv, rquat):
B += var * dim
B.texLabel='\\mathbf{B}'
display(Latex('Magnetic field $'+B.texLabel+'$ is defined with $B_x, B_y, B_z \\in \\mathbb{R}$'))
display(Math(B.texLabel+'=B_x'+sigma_1w.texLabel+'+B_y'+sigma_2w.texLabel+'+B_z'+sigma_3w.texLabel))
displayWithTitle(B, title=B.texLabel)
In [12]:
a, b, c, d = symbols('a b c d', real=True)
psiv =[b, c, d]
psi = S(a)
for (dim, var) in zip(psiv, rquat):
psi += var * dim
psi.texLabel='\\psi'
display(Latex('Pauli spinor $'+psi.texLabel+'$ is defined with $a, b, c, d\\in \\mathbb{R}$'))
display(Math(psi.texLabel+'=a+b'+sigma_1w.texLabel+'+c'+sigma_2w.texLabel+'+d'+sigma_3w.texLabel))
displayWithTitle(psi, title=psi.texLabel)
psiv_dagger =[-b, -c, -d]
psi_dagger = S(a)
for (dim, var) in zip(psiv_dagger, rquat):
psi_dagger += var * dim
psi_dagger.texLabel='\\psi^\\dagger'
display(Math(psi_dagger.texLabel+'=a-b'+sigma_1w.texLabel+'-c'+sigma_2w.texLabel+'-d'+sigma_3w.texLabel))
displayWithTitle(psi_dagger, title=psi_dagger.texLabel)
In [13]:
rho=psi*psi_dagger
rho.texLabel = '\\rho'
display(Math(rho.texLabel+'='+psi.texLabel+psi_dagger.texLabel))
displayWithTitle(rho, title=rho.texLabel)
spin_vector_w = psi*sigma_3w*psi_dagger
spin_vector_w.texLabel = '\\boldsymbol{s}_w'
display(Math(spin_vector_w.texLabel+'='+psi.texLabel+sigma_3w.texLabel+psi_dagger.texLabel))
displayWithTitle(spin_vector_w, title=spin_vector_w.texLabel)
In [14]:
up=1/2*(1+e_3)
up.texLabel='\\uparrow'
displayWithTitle(up, title=up.texLabel)
displayWithTitle(up*up, title=up.texLabel+'^2')
down=1/2*(1-e_3)
down.texLabel='\\downarrow'
displayWithTitle(down, title=down.texLabel)
displayWithTitle(down*down, title=down.texLabel+'^2')
In [15]:
gamma_5 = e_1*e_2*e_3*e_4
gamma_5.texLabel = '\\gamma_5'
left=1/2*(1-gamma_5)
left.texLabel='['
displayWithTitle(left, title=left.texLabel)
displayWithTitle(left*left, title=left.texLabel+'^2')
right=1/2*(1+gamma_5)
right.texLabel=']'
displayWithTitle(right, title=right.texLabel)
displayWithTitle(right*right, title=right.texLabel+'^2')
In [ ]: