Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Is it possible to return the grade of a multivector?

I have the following code:

from sage.algebras.clifford_algebra import CliffordAlgebra
from sage.quadratic_forms.quadratic_form import QuadraticForm
from sage.symbolic.ring import SR

# Define the quadratic form for GA(3,1) over the Symbolic Ring
Q = QuadraticForm(SR, 4, [-1, 0, 0, 0, 1, 0, 0, 1, 0, 1])

# Initialize the GA(3,1) algebra over the Symbolic Ring
algebra = CliffordAlgebra(Q)

# Define the basis vectors
e0, e1, e2, e3 = algebra.gens()

# Define the scalar variables for each basis element
a, t, x, y, z, f01, f02, f03, f12, f23, f13, v, w, q, p, b = var('a t x y z f01 f02 f03 f12 f23 f13 v w q p b')

# Create a general multivector
u = a+t*e0+x*e1+y*e2+z*e3+f01*e0*e1+f02*e0*e2+f03*e0*e3+f12*e1*e2+f13*e1*e3+f23*e2*e3

# Print the results
print(u)

Instead of printing u, I would like to print only a specific grade of u? But there is no function ex: u.grade(1) that returns the grade. I am looking for a way to specify a grade and return it: for instance:

print(u.grade(0)) #outputs a
print(u.grade(1)) #outputs t*e0+x*e1+y*e2+z*e3
print(u.grade(2)) #outputs f01*e0*e1+f02*e0*e2+f03*e0*e3+f12*e1*e2+f13*e1*e3+f23*e2*e3

etc...