Multivector and Linear Multivector Differential Operator


class, *args, ga, recp=None, **kwargs)[source]

Bases: galgebra.printer.GaPrintable

Wrapper class for multivector objects (self.obj) so that it is easy to overload operators (*, ^, |, <, >) for the various multivector products and for printing.

Also provides a constructor to easily instantiate multivector objects.

Additionally, the functionality of the multivector derivative have been added via the special vector grad so that one can take the geometric derivative of a multivector function A by applying grad from the left, grad*A, or the right A*grad for both the left and right derivatives. The operator between the grad and the ‘A’ can be any of the multivector product operators.

If f is a scalar function grad*f is the usual gradient of a function. If A is a vector function grad|f is the divergence of A and -I*(grad^A) is the curl of A (I is the pseudo scalar for the geometric algebra)


The underlying sympy expression for this multivector



Note this constructor is overloaded, based on the type and number of positional arguments:

class Mv(*, ga, recp=None)

Create a zero multivector

class Mv(expr, /, *, ga, recp=None)

Create a multivector from an existing vector or sympy expression

class Mv(coeffs, grade, /, ga, recp=None)

Create a multivector constant with a given grade

class Mv(name, category, /, *cat_args, ga, recp=None, f=False)

Create a multivector constant with a given category

class Mv(name, grade, /, ga, recp=None, f=False)

Create a multivector variable or function of a given grade

class Mv(coeffs, category, /, *cat_args, ga, recp=None)

Create a multivector variable or function of a given category

* and / in the signatures above are python 3.8 syntax, and respectively indicate the boundaries between positional-only, normal, and keyword-only arguments.

  • ga (Ga) – Geometric algebra to be used with multivectors

  • recp (object, optional) – Normalization for reciprocal vector. Unused.

  • name (str) – Name of this multivector, if it is a variable or function

  • coeffs (sequence) – Sequence of coefficients for the given category. This is only meaningful

  • category (str) –

    One of:

    • "grade" - this takes an additional argument, the grade to create, in cat_args

    • "scalar"

    • "vector"

    • "bivector" / "grade2"

    • "pseudo"

    • "mv"

    • "even" / "spinor"

    • "odd"

  • f (bool, tuple) – True if function of coordinates, or a tuple of those coordinates. Only valid if a name is passed

  • coords

    This argument is always accepted but ignored.

    It is incorrectly described internally as the coordinates to be used with multivector functions.

static setup(ga: Ga) → Tuple[Mv, List[Mv], Mv][source]

Set up constant multivectors required for multivector class for a given geometric algebra, ga.

static Mul(A:, B:, op: str)[source]

Function for all types of geometric multiplications called by overloaded operators for *, ^, |, <, and >.


Express as a linear combination of geometric products


Express as a linear combination of blades


group coeffients of blades of multivector so there is only one coefficient per grade


True is self is blade, otherwise False sets self.blade_flg and returns value


Test for versor (geometric product of vectors)

This follows Leo Dorst’s test for a versor. Leo Dorst, ‘Geometric Algebra for Computer Science,’ p.533 Sets self.versor_flg and returns value


return scalar part of multivector as sympy expression

get_grade(r: int)[source]

return r-th grade of multivector as a multivector

get_coefs(grade: int) → List[sympy.core.expr.Expr][source]

Like blade_coefs(self.Ga.mv_blades[grade]), but requires all components to be of that grade.

:raises ValueError:: If the multivector is not of the given grade.

blade_coefs(blade_lst: List[Mv] = None) → List[sympy.core.expr.Expr][source]

For a multivector, A, and a list of basis blades, blade_lst return a list (sympy expressions) of the coefficients of each basis blade in blade_lst

proj(bases_lst: List[Mv])[source]

Project multivector onto a given list of bases. That is find the part of multivector with the same bases as in the bases_lst.


return even parts of multivector


return odd parts of multivector

Grad(coords, mode: str = '*', left: bool = True)[source]

Returns various derivatives (*, ^, |, <, >) of multivector functions with respect to arbitrary coordinates, ‘coords’.

This would be used where you have a multivector function of both the basis coordinate set and and auxiliary coordinate set. Consider for example a linear transformation in which the matrix coefficients depend upon the manifold coordinates, but the vector being transformed does not and you wish to take the divergence of the linear transformation with respect to the linear argument.

exp(hint: str = '-')[source]

Only works if square of multivector is a scalar. If square is a number we can determine if square is > or < zero and hence if one should use trig or hyperbolic functions in expansion. If square is not a number use ‘hint’ to determine which type of functions to use in expansion

Fmt(fmt: int = 1, title: str = None)galgebra.printer.GaPrintable[source]

Set format for printing of multivectors

  • fmt=1 - One multivector per line

  • fmt=2 - One grade per line

  • fmt=3 - one base per line

Usage for multivector A example is:

A.Fmt('2', 'A')

output is:

'A = '+str(A)

with one grade per line. Works for both standard printing and for latex.

norm(hint: str = '+')sympy.core.expr.Expr[source]

If A is a multivector and A*A.rev() is a scalar then:

A.norm() == sqrt(Abs(A*A.rev()))

The problem in simplifying the norm is that if A is symbolic you don’t know if A*A.rev() is positive or negative. The use of the hint argument is as follows:









The default hint='+' is correct for vectors in a Euclidean vector space. For bivectors in a Euclidean vector space use hint='-'. In a mixed signature space all bets are off for the norms of symbolic expressions.

simplify(modes=<function simplify>)[source]

Simplify a multivector by scalar (sympy) simplifications.

modes is an operation or sequence of operations to apply to the the coefficients of a multivector expansion.

subs(*args, **kwargs)[source]

Perform a substitution on each coefficient separately


For pure grade return grade. If not pure grade return negative of maximum grade, B: → Union[sympy.core.expr.Expr, int][source]

Determine if B = c*A where c is a scalar. If true return c otherwise return 0.

class*args, ga: Ga, cmpflg: bool = False, debug: bool = False)[source]

Bases: galgebra.dop._BaseDop

Differential operator class for multivectors. The operators are of the form

\[D = D^{i_{1}...i_{n}}\partial_{i_{1}...i_{n}}\]

where the \(D^{i_{1}...i_{n}}\) are multivector functions of the coordinates \(x_{1},...,x_{n}\) and \(\partial_{i_{1}...i_{n}}\) are partial derivative operators

\[\partial_{i_{1}...i_{n}} = \frac{\partial^{i_{1}+...+i_{n}}}{\partial{x_{1}^{i_{1}}}...\partial{x_{n}^{i_{n}}}}.\]

If \(*\) is any multivector multiplicative operation then the operator D operates on the multivector function \(F\) by the following definitions

\[D*F = D^{i_{1}...i_{n}}*\partial_{i_{1}...i_{n}}F\]

returns a multivector and

\[F*D = F*D^{i_{1}...i_{n}}\partial_{i_{1}...i_{n}}\]

returns a differential operator. If the cmpflg in the operator is set to True the operation returns

\[F*D = (\partial_{i_{1}...i_{n}}F)*D^{i_{1}...i_{n}}\]

a multivector function. For example the representation of the grad operator in 3d would be:

\[\begin{split}D^{i_{1}...i_{n}} &= [e_x,e_y,e_z] \\ \partial_{i_{1}...i_{n}} &= [(1,0,0),(0,1,0),(0,0,1)].\end{split}\]

See LaTeX documentation for definitions of operator algebraic operations +, -, *, ^, |, <, and >.


Associated geometric algebra




Complement flag




list of tuples

  • ga – Associated geometric algebra

  • cmpflg (bool) – Complement flag for Dop

  • debug (bool) – True to print out debugging information

simplify(modes=<function simplify>)[source]

Simplify each multivector coefficient of a partial derivative


Remove zero coefs and consolidate coefs with repeated pdiffs., prec=5)[source]

Like sympy.N(), but also works on multivectors

For multivectors with coefficients that contain floating point numbers, this rounds all these numbers to a precision of prec and returns the rounded multivector., v2:[source]

If v1 and v2 are 3-dimensional Euclidean vectors, compute the vector cross product \(v_{1}\times v_{2} = -I{\lp {v_{1}{\wedge}v_{2}} \rp }\).[source]

Equivalent to Mv.dual()[source]

Equivalent to Mv.even()[source]

Equivalent to Mv.odd() Union[, sympy.core.expr.Expr], hint: str = '-') → Union[, sympy.core.expr.Expr][source]

If A is a multivector then A.exp(hint) is returned. If A is a sympy expression the sympy expression \(e^{A}\) is returned (see sympy.exp())., r: int = 0)[source]

Equivalent to Mv.grade()[source]

Equivalent to Mv.inv(), hint: str = '+')sympy.core.expr.Expr[source]

Equivalent to Mv.norm()[source]

Equivalent to Mv.norm2(), A:[source]

Equivalent to Mv.project_in_blade(), A:, hint: str = '-')[source]

Equivalent to A.rotate_multivector(itheta, hint) where itheta is the bi-vector blade defining the rotation. For the use of hint see the method Mv.rotate_multivector()., A:[source]

Reflect multivector \(A\) in blade \(B\).

If \(s\) is grade of \(B\) returns \(\sum_{r}(-1)^{s(r+1)}B{\left < {A} \right >}_{r}B^{-1}\).

Equivalent to Mv.reflect_in_blade()[source]

Equivalent to Mv.rev()[source]

Equivalent to Mv.scalar()