Question

For example, I'd like to define x and y as non-commutative, and a and b as commutative (as usual). In other words,

x y ≠ y x,  a x = x a,  a b = b a .

Further,

(x + a y) (x - a y) = x^2 + a (y x - x y) - a^2 y^2 .

What is a code for defining x and y, and a symbol for multiplication (such as * and . ) ?

Was it helpful?

Solution

You can work with Maxima's commutative * and non-commutative . products in the way that you want by following the next two steps:

  1. Declare the symbols a and b as scalars:

    declare([a, b], scalar)$

  2. Enable dotscrules:

    dotscrules: true$

    This simplifies non-commutative products involving scalars to commutative products (i.e., a.x becomes a*x).

Now you are ready. For example,

expand((a*x + b*y) . (a*x - b*y))

returns

a*b*y.x - b^2*y^^2 - a*b*x.y + a^2*x^^2

(note that ^^ is the non-commutative exponentiation operator).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top