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 .
) ?
You can work with Maxima's commutative *
and non-commutative .
products in the way that you want by following the next two steps:
Declare the symbols
a
andb
as scalars:declare([a, b], scalar)$
Enable
dotscrules
:dotscrules: true$
This simplifies non-commutative products involving scalars to commutative products (i.e.,
a.x
becomesa*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).
精彩评论