This page was generated from docs/tutorials/space-time-algebra.ipynb. Interactive online version: .

# Space Time Algebra¶

## Intro¶

This notebook demonstrates how to use `clifford`

to work with Space Time Algebra. The Pauli algebra of space \(\mathbb{P}\), and Dirac algebra of space-time \(\mathbb{D}\), are related using the *spacetime split*. The split is implemented by using a `BladeMap`

(docs), which maps a subset of blades in \(\mathbb{D}\) to the blades in \(\mathbb{P}\). This *split* allows a spacetime bivector \(F\) to be broken up into relative
electric and magnetic fields in space. Lorentz transformations are implemented as rotations in \(\mathbb{D}\), and the effects on the relative fields are computed with the split.

## Setup¶

First we import `clifford`

, instantiate the two algebras, and populate the namespace with the blades of each algebra. The elements of \(\mathbb{D}\) are prefixed with \(d\), while the elements of \(\mathbb{P}\) are prefixed with \(p\). Although unconventional, it is easier to read and to translate into code.

```
[1]:
```

```
from clifford import Cl, pretty
pretty(precision=1)
# Dirac Algebra `D`
D, D_blades = Cl(1,3, firstIdx=0, names='d')
# Pauli Algebra `P`
P, P_blades = Cl(3, names='p')
# put elements of each in namespace
locals().update(D_blades)
locals().update(P_blades)
```

## The Space Time Split¶

To two algebras can be related by the spacetime-split. First, we create a `BladeMap`

which relates the bivectors in \(\mathbb{D}\) to the vectors/bivectors in \(\mathbb{P}\). The scalars and pseudo-scalars in each algebra are equated.

```
[2]:
```

```
from clifford import BladeMap
bm = BladeMap([(d01,p1),
(d02,p2),
(d03,p3),
(d12,p12),
(d23,p23),
(d13,p13),
(d0123, p123)])
```

## Splitting a space-time vector (an event)¶

A vector in \(\mathbb{D}\), represents a unique place in space and time, i.e. an event. To illustrate the split, create a random event \(X\).

```
[3]:
```

```
X = D.randomV()*10
X
```

```
[3]:
```

```
-(18.6^d0) - (5.0^d1) - (17.1^d2) - (1.0^d3)
```

This can be *split* into time and space components by multiplying with the time-vector \(d_0\),

```
[4]:
```

```
X*d0
```

```
[4]:
```

```
-18.6 + (5.0^d01) + (17.1^d02) + (1.0^d03)
```

and applying the `BladeMap`

, which results in a scalar+vector in \(\mathbb{P}\)

```
[5]:
```

```
bm(X*d0)
```

```
[5]:
```

```
-18.6 + (5.0^p1) + (17.1^p2) + (1.0^p3)
```

The space and time components can be separated by grade projection,

```
[6]:
```

```
x = bm(X*d0)
x(0) # the time component
```

```
[6]:
```

```
-18.6
```

```
[7]:
```

```
x(1) # the space component
```

```
[7]:
```

```
(5.0^p1) + (17.1^p2) + (1.0^p3)
```

We therefor define a `split()`

function, which has a simple condition allowing it to act on a vector or a multivector in \(\mathbb{D}\). Splitting a spacetime bivector will be treated in the next section.

```
[8]:
```

```
def split(X):
return bm(X.odd*d0+X.even)
```

```
[9]:
```

```
split(X)
```

```
[9]:
```

```
-18.6 + (5.0^p1) + (17.1^p2) + (1.0^p3)
```

The split can be inverted by applying the `BladeMap`

again, and multiplying by \(d_0\)

```
[10]:
```

```
x = split(X)
bm(x)*d0
```

```
[10]:
```

```
-(18.6^d0) - (5.0^d1) - (17.1^d2) - (1.0^d3)
```

## Splitting a Bivector¶

Given a random bivector \(F\) in \(\mathbb{D}\),

```
[11]:
```

```
F = D.randomMV()(2)
F
```

```
[11]:
```

```
-(1.7^d01) - (0.6^d02) + (1.8^d03) + (0.9^d12) + (0.2^d13) + (1.1^d23)
```

\(F\) *splits* into a vector/bivector in \(\mathbb{P}\)

```
[12]:
```

```
split(F)
```

```
[12]:
```

```
-(1.7^p1) - (0.6^p2) + (1.8^p3) + (0.9^p12) + (0.2^p13) + (1.1^p23)
```

If \(F\) is interpreted as the electromagnetic bivector, the Electric and Magnetic fields can be separated by grade

```
[13]:
```

```
E = split(F)(1)
iB = split(F)(2)
E
```

```
[13]:
```

```
-(1.7^p1) - (0.6^p2) + (1.8^p3)
```

```
[14]:
```

```
iB
```

```
[14]:
```

```
(0.9^p12) + (0.2^p13) + (1.1^p23)
```

## Lorentz Transformations¶

Lorentz Transformations are rotations in \(\mathbb{D}\), which are implemented with Rotors. A rotor in G4 will, in general, have scalar, bivector, and quadvector components.

```
[15]:
```

```
R = D.randomRotor()
R
```

```
[15]:
```

```
0.3 - (1.8^d01) - (2.0^d02) - (0.8^d03) - (0.7^d12) - (2.1^d13) - (2.0^d23) + (0.2^d0123)
```

In this way, the effect of a lorentz transformation on the electric and magnetic fields can be computed by rotating the bivector with \(F \rightarrow RF\tilde{R}\)

```
[16]:
```

```
F_ = R*F*~R
F_
```

```
[16]:
```

```
(28.6^d01) + (23.0^d02) + (14.4^d03) + (8.5^d12) + (31.9^d13) + (21.4^d23)
```

Then splitting into \(E\) and \(B\) fields

```
[17]:
```

```
E_ = split(F_)(1)
E_
```

```
[17]:
```

```
(28.6^p1) + (23.0^p2) + (14.4^p3)
```

```
[18]:
```

```
iB_ = split(F_)(2)
iB_
```

```
[18]:
```

```
(8.5^p12) + (31.9^p13) + (21.4^p23)
```

## Lorentz Invariants¶

Since lorentz rotations in \(\mathbb{D}\), the magnitude of elements of \(\mathbb{D}\) are invariants of the lorentz transformation. For example, the magnitude of electromagnetic bivector \(F\) is invariant, and it can be related to \(E\) and \(B\) fields in \(\mathbb{P}\) through the split,

```
[19]:
```

```
i = p123
E = split(F)(1)
B = -i*split(F)(2)
```

```
[20]:
```

```
F**2
```

```
[20]:
```

```
4.6 - (0.2^d0123)
```

```
[21]:
```

```
split(F**2) == E**2 - B**2 + (2*E|B)*i
```

```
[21]:
```

```
True
```