set_anticommutative ======================================== .. py:function:: grassmanntn.arith.set_anticommutative(generators) .. py:function:: 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:** - **out:** `grassmann_number `__ If `generators` is ``str``, returns a `grassmann_number `__. If `generators` is a list of ``str``, returns an array of `grassmann_number `__ (a spinor). Examples ++++++++ Basic Grassmann number operations. .. code-block:: python >>> 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. .. code-block:: python >>> ψ = 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. .. code-block:: python >>> 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: .. code-block:: python >>> 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