set_anticommutative

grassmanntn.arith.set_anticommutative(generators)
grassmanntn.arith.set_ac(generators)

Define an anticommuting variable with the symbol given by generators.

Parameters:

  • generators: str or a list of str

    A string or a list of strings representing Grassmann generators.

Returns:

Examples

Basic Grassmann number operations.

>>> from grassmanntn import arith
>>> θ1 = arith.set_ac(["θ1"])
>>> θ2 = arith.set_ac(["θ2"])
>>> x = θ1*θ2+θ1
>>> print(x)
(1)*θ1 + (1)*θ1^θ2
>>> print(x + θ2*θ1)   # θ2*θ1 = -θ1*θ2
(1)*θ1

It can also handle a multi-component Grassmann number; i.e., a spinor.

>>> ψ = arith.set_ac(["ψ1","ψ2"])
>>> φ = arith.set_ac(["φ1","φ2"])
>>> print(φ @ ψ)                # a dot product of two spinors
(1)*φ1^ψ1 + (1)*φ2^ψ2

One can also easily form a fermionic bilinear.

>>> import numpy as np
>>> D = np.array( [ [1,2], [3,4] ] )
>>> print(φ @ D @ ψ)            # a more general bilinear
(1)*φ1^ψ1 + (3)*φ2^ψ1 + (2)*φ1^ψ2 + (4)*φ2^ψ2

Symbolic computation is also supported:

>>> import sympy
>>> a = sympy.symbols("a")
>>> b = sympy.symbols("b")
>>> c = sympy.symbols("c")
>>> d = sympy.symbols("d")
>>> K = np.array( [[a,b],[c,d]] )
>>> φ @ K @ ψ
(a)*φ1^ψ1 + (c)*φ2^ψ1 + (b)*φ1^ψ2 + (d)*φ2^ψ2