Feeds:
Posts

## SAGE tip: Creating a Class for non-Abelian forms.

Hi everyone, today I start to write a new class for dealing with non-Abelian forms, i.e., forms with values in a certain Lie-algebra. This could be really useful when computing Yang-Mills theories in physics.

So, I started by defining a new object which have two entries, a differential form and a matrix, and call it nAform. The code I wrote was,

```class nAform(object):
def __init__(self, a, b):
self._form = a
self._matrix = b
if isinstance(other, nAform):
if (self._matrix == other._matrix):
return nAform(self._form + other._form, self._matrix)
else:
return NotImplemented
return NotImplemented
def __mul__(self, other):
if isinstance(other, nAform):
return nAform(self._form.wedge(other._form), self._matrix.commutator(other._matrix))
return NotImplemented
def diff(self):
return nAform(self._form.diff(), self._matrix)
def __repr__(self):
return str((self._form, self._matrix))
def __str__(self):
return self.__repr__()```

## Explanation

One should enter a couple of arguments when defining the nAform object. The __init__ attribute recognize them.

Then an addition attribute is defined, this is incomplete!!!

Another attribute is the multiplication, which take the wedge product of the forms and the commutator of the matrices.

I also implement the exterior derivative on nAform objects.

Finally the __repr__ and __str__ are attributes for returning the data.

## TO-DO

• I couldn’t implement the addition of nAform’s if the matrices are different. As
Nicolas M. Thiery note, this objects should define a Monoid (or something quit close to it). But my programming skills are not so developed.
• It would be great if one could define the multiplication by a constant or function.
• The show attribute is not implemented, but one can show either forms of matrices by themselves… I think that is someone knows how they work, would be easy to do that! ðŸ˜‰
• One could try to implement the simplification attributes on differential forms.
• I don’t remember exactly why I was looking for it, but I think could be useful to define and attribute on forms which show the generator, like .gens(), but for a given differential form, say
```sage: x, y, z = var('x, y, z')
sage: U = CoordinatePatch((x, y, z)); U
Open subset of R^3 with coordinates x, y, z
sage: F = DifferentialForms(U); F
Algebra of differential forms in the variables x, y, z
sage: F.gens()
(dx, dy, dz)
sage: F.ngens()
3```

I’d like one which do like this,

```sage: form1 = DifferentialForm(F, 1); form1.ngens()
3
sage: form1 = DifferentialForm(F, 1); form1.gens()
(dx, dy, dz)
form2 = DifferentialForm(F, 2); form2.ngens()
3
sage: form1 = DifferentialForm(F, 1); form1.gens()
(dx/\dy, dy/\dz, dz/\dx)```
• ## Simple SAGE sheet

Worksheet

Hope you can help me with these plenty tasks.

Enjoy!

Dox

### 5 Responses

1. A while ago, I became interested in incorporating Clifford algebras into Sage, via my GluCat library and by other means. Would your method also work for Clifford-valued differential forms, as per (e.g.) Sommen’s formulation http://www.jstor.org/pss/2001776 ?

• The final goal would be to be able of working with any field theory, as you point, Dirac equations, as well as General Ralativity (see my previous posts, e.g., this).

Of course it’s a lot of work… I’m a grad student, and neither my time for programming nor my skills are plenty. ðŸ˜›

Would you share the code of your class? For trying to put all of them together!

Thx.

Dox

• I’ve found this, on sympy doc.

ðŸ™‚

2. Hi Dox,

This is great code! I just wanted to say that I’ve added your blog posts to my Wiki page on tensor analysis with Sage: http://wiki.sagemath.org/tensorcalc

PS: happy (belated) birthday!

• Hi Joris,

Thank you for gathering all that documentation, including me in that, and the delayed congratz!
ðŸ˜‰

b.t.w., saw your last paper (todays). Great!