This notebook verifies doc/python/*.py

BACCAB.py


In [1]:
import sympy

In [2]:
from __future__ import absolute_import, division
from __future__ import print_function
from galgebra.printer import Format, xpdf
from galgebra.ga import Ga

In [3]:
Format()

In [4]:
g4d = Ga('a b c d')

In [5]:
(a, b, c, d) = g4d.mv()

In [6]:
g4d.g


Out[6]:
$\displaystyle \left[\begin{matrix}(a.a) & (a.b) & (a.c) & (a.d)\\(a.b) & (b.b) & (b.c) & (b.d)\\(a.c) & (b.c) & (c.c) & (c.d)\\(a.d) & (b.d) & (c.d) & (d.d)\end{matrix}\right]$

In [7]:
a | (b * c)


Out[7]:
\begin{equation*} - \left ( a\cdot c\right ) \boldsymbol{b} + \left ( a\cdot b\right ) \boldsymbol{c} \end{equation*}

In [8]:
a | (b ^ c)


Out[8]:
\begin{equation*} - \left ( a\cdot c\right ) \boldsymbol{b} + \left ( a\cdot b\right ) \boldsymbol{c} \end{equation*}

In [9]:
a | (b ^ c ^ d)


Out[9]:
\begin{equation*} \left ( a\cdot d\right ) \boldsymbol{b}\wedge \boldsymbol{c} - \left ( a\cdot c\right ) \boldsymbol{b}\wedge \boldsymbol{d} + \left ( a\cdot b\right ) \boldsymbol{c}\wedge \boldsymbol{d} \end{equation*}

In [10]:
(a | (b ^ c)) + (c | (a ^ b)) + (b | (c ^ a))


Out[10]:
\begin{equation*} 0 \end{equation*}

In [11]:
a * (b ^ c) - b * (a ^ c) + c * (a ^ b)


Out[11]:
\begin{equation*} 3 \boldsymbol{a}\wedge \boldsymbol{b}\wedge \boldsymbol{c} \end{equation*}

In [12]:
a * (b ^ c ^ d) - b * (a ^ c ^ d) + c * (a ^ b ^ d) - d * (a ^ b ^ c)


Out[12]:
\begin{equation*} 4 \boldsymbol{a}\wedge \boldsymbol{b}\wedge \boldsymbol{c}\wedge \boldsymbol{d} \end{equation*}

In [13]:
(a ^ b) | (c ^ d)


Out[13]:
\begin{equation*} - \left ( a\cdot c\right ) \left ( b\cdot d\right ) + \left ( a\cdot d\right ) \left ( b\cdot c\right ) \end{equation*}

In [14]:
((a ^ b) | c) | d


Out[14]:
\begin{equation*} - \left ( a\cdot c\right ) \left ( b\cdot d\right ) + \left ( a\cdot d\right ) \left ( b\cdot c\right ) \end{equation*}

In [15]:
Ga.com(a ^ b, c ^ d)


Out[15]:
\begin{equation*} - \left ( b\cdot d\right ) \boldsymbol{a}\wedge \boldsymbol{c} + \left ( b\cdot c\right ) \boldsymbol{a}\wedge \boldsymbol{d} + \left ( a\cdot d\right ) \boldsymbol{b}\wedge \boldsymbol{c} - \left ( a\cdot c\right ) \boldsymbol{b}\wedge \boldsymbol{d} \end{equation*}

Dirac.py


In [16]:
from __future__ import absolute_import, division
from __future__ import print_function
import sys
from sympy import symbols, sin, cos
from galgebra.printer import Format, xpdf, Get_Program, Print_Function
from galgebra.ga import Ga

In [17]:
Format()
coords = symbols('t x y z', real=True)
coords


Out[17]:
$\displaystyle \left( t, \ x, \ y, \ z\right)$

In [18]:
(st4d, g0, g1, g2, g3) = Ga.build(
    'gamma*t|x|y|z', g=[1, -1, -1, -1], coords=coords)

In [19]:
g0


Out[19]:
\begin{equation*} \boldsymbol{\gamma }_{t} \end{equation*}

In [20]:
g1


Out[20]:
\begin{equation*} \boldsymbol{\gamma }_{x} \end{equation*}

In [21]:
g2


Out[21]:
\begin{equation*} \boldsymbol{\gamma }_{y} \end{equation*}

In [22]:
g3


Out[22]:
\begin{equation*} \boldsymbol{\gamma }_{z} \end{equation*}

In [23]:
I = st4d.i
I


Out[23]:
\begin{equation*} \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{equation*}

In [24]:
(m, e) = symbols('m e')

In [25]:
m


Out[25]:
$\displaystyle m$

In [26]:
e


Out[26]:
$\displaystyle e$

In [27]:
# 4-Vector Potential
A = st4d.mv('A', 'vector', f=True)
A


Out[27]:
\begin{equation*} A = A^{t} \boldsymbol{\gamma }_{t} + A^{x} \boldsymbol{\gamma }_{x} + A^{y} \boldsymbol{\gamma }_{y} + A^{z} \boldsymbol{\gamma }_{z} \end{equation*}

In [28]:
# 8-componentrealspinor
psi = st4d.mv('psi', 'spinor', f=True)
psi


Out[28]:
\begin{equation*} psi = \psi + \psi ^{tx} \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x} + \psi ^{ty} \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{y} + \psi ^{tz} \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{z} + \psi ^{xy} \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y} + \psi ^{xz} \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{z} + \psi ^{yz} \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} + \psi ^{txyz} \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{equation*}

In [29]:
sig_z = g3 * g0
sig_z


Out[29]:
\begin{equation*} - \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{z} \end{equation*}

Dirac Equation $\newcommand{bm}[1]{\boldsymbol #1} \nabla \bm{\psi} I \sigma_{z}-e\bm{A}\bm{\psi}-m\bm{\psi}\gamma_{t} = 0$


In [30]:
dirac_eq = (st4d.grad * psi) * I * sig_z - e * A * psi - m * psi * g0
dirac_eq


Out[30]:
\begin{equation*} \left ( - e A^{t} \psi - e A^{x} \psi ^{tx} - e A^{y} \psi ^{ty} - e A^{z} \psi ^{tz} - m \psi - \partial_{y} \psi ^{tx} - \partial_{z} \psi ^{txyz} + \partial_{x} \psi ^{ty} + \partial_{t} \psi ^{xy} \right ) \boldsymbol{\gamma }_{t} + \left ( - e A^{t} \psi ^{tx} - e A^{x} \psi - e A^{y} \psi ^{xy} - e A^{z} \psi ^{xz} + m \psi ^{tx} + \partial_{y} \psi - \partial_{t} \psi ^{ty} - \partial_{x} \psi ^{xy} + \partial_{z} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x} + \left ( - e A^{t} \psi ^{ty} + e A^{x} \psi ^{xy} - e A^{y} \psi - e A^{z} \psi ^{yz} + m \psi ^{ty} - \partial_{x} \psi + \partial_{t} \psi ^{tx} - \partial_{y} \psi ^{xy} - \partial_{z} \psi ^{xz} \right ) \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{tz} + e A^{x} \psi ^{xz} + e A^{y} \psi ^{yz} - e A^{z} \psi + m \psi ^{tz} + \partial_{t} \psi ^{txyz} - \partial_{z} \psi ^{xy} + \partial_{y} \psi ^{xz} - \partial_{x} \psi ^{yz} \right ) \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{xy} + e A^{x} \psi ^{ty} - e A^{y} \psi ^{tx} - e A^{z} \psi ^{txyz} - m \psi ^{xy} - \partial_{t} \psi + \partial_{x} \psi ^{tx} + \partial_{y} \psi ^{ty} + \partial_{z} \psi ^{tz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{xz} + e A^{x} \psi ^{tz} + e A^{y} \psi ^{txyz} - e A^{z} \psi ^{tx} - m \psi ^{xz} + \partial_{x} \psi ^{txyz} + \partial_{z} \psi ^{ty} - \partial_{y} \psi ^{tz} - \partial_{t} \psi ^{yz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{yz} - e A^{x} \psi ^{txyz} + e A^{y} \psi ^{tz} - e A^{z} \psi ^{ty} - m \psi ^{yz} - \partial_{z} \psi ^{tx} + \partial_{y} \psi ^{txyz} + \partial_{x} \psi ^{tz} + \partial_{t} \psi ^{xz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{txyz} - e A^{x} \psi ^{yz} + e A^{y} \psi ^{xz} - e A^{z} \psi ^{xy} + m \psi ^{txyz} + \partial_{z} \psi - \partial_{t} \psi ^{tz} - \partial_{x} \psi ^{xz} - \partial_{y} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{equation*}

In [31]:
dirac_eq.Fmt(2)


Out[31]:
\begin{align*} & \left ( - e A^{t} \psi - e A^{x} \psi ^{tx} - e A^{y} \psi ^{ty} - e A^{z} \psi ^{tz} - m \psi - \partial_{y} \psi ^{tx} - \partial_{z} \psi ^{txyz} + \partial_{x} \psi ^{ty} + \partial_{t} \psi ^{xy} \right ) \boldsymbol{\gamma }_{t} + \left ( - e A^{t} \psi ^{tx} - e A^{x} \psi - e A^{y} \psi ^{xy} - e A^{z} \psi ^{xz} + m \psi ^{tx} + \partial_{y} \psi - \partial_{t} \psi ^{ty} - \partial_{x} \psi ^{xy} + \partial_{z} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x} + \left ( - e A^{t} \psi ^{ty} + e A^{x} \psi ^{xy} - e A^{y} \psi - e A^{z} \psi ^{yz} + m \psi ^{ty} - \partial_{x} \psi + \partial_{t} \psi ^{tx} - \partial_{y} \psi ^{xy} - \partial_{z} \psi ^{xz} \right ) \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{tz} + e A^{x} \psi ^{xz} + e A^{y} \psi ^{yz} - e A^{z} \psi + m \psi ^{tz} + \partial_{t} \psi ^{txyz} - \partial_{z} \psi ^{xy} + \partial_{y} \psi ^{xz} - \partial_{x} \psi ^{yz} \right ) \boldsymbol{\gamma }_{z} \\ & + \left ( - e A^{t} \psi ^{xy} + e A^{x} \psi ^{ty} - e A^{y} \psi ^{tx} - e A^{z} \psi ^{txyz} - m \psi ^{xy} - \partial_{t} \psi + \partial_{x} \psi ^{tx} + \partial_{y} \psi ^{ty} + \partial_{z} \psi ^{tz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{xz} + e A^{x} \psi ^{tz} + e A^{y} \psi ^{txyz} - e A^{z} \psi ^{tx} - m \psi ^{xz} + \partial_{x} \psi ^{txyz} + \partial_{z} \psi ^{ty} - \partial_{y} \psi ^{tz} - \partial_{t} \psi ^{yz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{yz} - e A^{x} \psi ^{txyz} + e A^{y} \psi ^{tz} - e A^{z} \psi ^{ty} - m \psi ^{yz} - \partial_{z} \psi ^{tx} + \partial_{y} \psi ^{txyz} + \partial_{x} \psi ^{tz} + \partial_{t} \psi ^{xz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{txyz} - e A^{x} \psi ^{yz} + e A^{y} \psi ^{xz} - e A^{z} \psi ^{xy} + m \psi ^{txyz} + \partial_{z} \psi - \partial_{t} \psi ^{tz} - \partial_{x} \psi ^{xz} - \partial_{y} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{align*}

In [32]:
dirac_eq = dirac_eq.simplify()
dirac_eq


Out[32]:
\begin{align*} & \left ( - e A^{t} \psi - e A^{x} \psi ^{tx} - e A^{y} \psi ^{ty} - e A^{z} \psi ^{tz} - m \psi - \partial_{y} \psi ^{tx} - \partial_{z} \psi ^{txyz} + \partial_{x} \psi ^{ty} + \partial_{t} \psi ^{xy} \right ) \boldsymbol{\gamma }_{t} + \left ( - e A^{t} \psi ^{tx} - e A^{x} \psi - e A^{y} \psi ^{xy} - e A^{z} \psi ^{xz} + m \psi ^{tx} + \partial_{y} \psi - \partial_{t} \psi ^{ty} - \partial_{x} \psi ^{xy} + \partial_{z} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x} + \left ( - e A^{t} \psi ^{ty} + e A^{x} \psi ^{xy} - e A^{y} \psi - e A^{z} \psi ^{yz} + m \psi ^{ty} - \partial_{x} \psi + \partial_{t} \psi ^{tx} - \partial_{y} \psi ^{xy} - \partial_{z} \psi ^{xz} \right ) \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{tz} + e A^{x} \psi ^{xz} + e A^{y} \psi ^{yz} - e A^{z} \psi + m \psi ^{tz} + \partial_{t} \psi ^{txyz} - \partial_{z} \psi ^{xy} + \partial_{y} \psi ^{xz} - \partial_{x} \psi ^{yz} \right ) \boldsymbol{\gamma }_{z} \\ & + \left ( - e A^{t} \psi ^{xy} + e A^{x} \psi ^{ty} - e A^{y} \psi ^{tx} - e A^{z} \psi ^{txyz} - m \psi ^{xy} - \partial_{t} \psi + \partial_{x} \psi ^{tx} + \partial_{y} \psi ^{ty} + \partial_{z} \psi ^{tz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{xz} + e A^{x} \psi ^{tz} + e A^{y} \psi ^{txyz} - e A^{z} \psi ^{tx} - m \psi ^{xz} + \partial_{x} \psi ^{txyz} + \partial_{z} \psi ^{ty} - \partial_{y} \psi ^{tz} - \partial_{t} \psi ^{yz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{yz} - e A^{x} \psi ^{txyz} + e A^{y} \psi ^{tz} - e A^{z} \psi ^{ty} - m \psi ^{yz} - \partial_{z} \psi ^{tx} + \partial_{y} \psi ^{txyz} + \partial_{x} \psi ^{tz} + \partial_{t} \psi ^{xz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{txyz} - e A^{x} \psi ^{yz} + e A^{y} \psi ^{xz} - e A^{z} \psi ^{xy} + m \psi ^{txyz} + \partial_{z} \psi - \partial_{t} \psi ^{tz} - \partial_{x} \psi ^{xz} - \partial_{y} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{align*}

In [33]:
dirac_eq.Fmt(2)


Out[33]:
\begin{align*} & \left ( - e A^{t} \psi - e A^{x} \psi ^{tx} - e A^{y} \psi ^{ty} - e A^{z} \psi ^{tz} - m \psi - \partial_{y} \psi ^{tx} - \partial_{z} \psi ^{txyz} + \partial_{x} \psi ^{ty} + \partial_{t} \psi ^{xy} \right ) \boldsymbol{\gamma }_{t} + \left ( - e A^{t} \psi ^{tx} - e A^{x} \psi - e A^{y} \psi ^{xy} - e A^{z} \psi ^{xz} + m \psi ^{tx} + \partial_{y} \psi - \partial_{t} \psi ^{ty} - \partial_{x} \psi ^{xy} + \partial_{z} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x} + \left ( - e A^{t} \psi ^{ty} + e A^{x} \psi ^{xy} - e A^{y} \psi - e A^{z} \psi ^{yz} + m \psi ^{ty} - \partial_{x} \psi + \partial_{t} \psi ^{tx} - \partial_{y} \psi ^{xy} - \partial_{z} \psi ^{xz} \right ) \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{tz} + e A^{x} \psi ^{xz} + e A^{y} \psi ^{yz} - e A^{z} \psi + m \psi ^{tz} + \partial_{t} \psi ^{txyz} - \partial_{z} \psi ^{xy} + \partial_{y} \psi ^{xz} - \partial_{x} \psi ^{yz} \right ) \boldsymbol{\gamma }_{z} \\ & + \left ( - e A^{t} \psi ^{xy} + e A^{x} \psi ^{ty} - e A^{y} \psi ^{tx} - e A^{z} \psi ^{txyz} - m \psi ^{xy} - \partial_{t} \psi + \partial_{x} \psi ^{tx} + \partial_{y} \psi ^{ty} + \partial_{z} \psi ^{tz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y} + \left ( - e A^{t} \psi ^{xz} + e A^{x} \psi ^{tz} + e A^{y} \psi ^{txyz} - e A^{z} \psi ^{tx} - m \psi ^{xz} + \partial_{x} \psi ^{txyz} + \partial_{z} \psi ^{ty} - \partial_{y} \psi ^{tz} - \partial_{t} \psi ^{yz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{yz} - e A^{x} \psi ^{txyz} + e A^{y} \psi ^{tz} - e A^{z} \psi ^{ty} - m \psi ^{yz} - \partial_{z} \psi ^{tx} + \partial_{y} \psi ^{txyz} + \partial_{x} \psi ^{tz} + \partial_{t} \psi ^{xz} \right ) \boldsymbol{\gamma }_{t}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} + \left ( - e A^{t} \psi ^{txyz} - e A^{x} \psi ^{yz} + e A^{y} \psi ^{xz} - e A^{z} \psi ^{xy} + m \psi ^{txyz} + \partial_{z} \psi - \partial_{t} \psi ^{tz} - \partial_{x} \psi ^{xz} - \partial_{y} \psi ^{yz} \right ) \boldsymbol{\gamma }_{x}\wedge \boldsymbol{\gamma }_{y}\wedge \boldsymbol{\gamma }_{z} \end{align*}

In [ ]: