开发者

How to define some variables as non-commutative in Maxima

开发者 https://www.devze.com 2023-04-03 03:46 出处:网络
For example, I\'d like to define x and y 开发者_运维百科as non-commutative, and a and b as commutative (as usual). In other words,

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:

  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).

0

精彩评论

暂无评论...
验证码 换一张
取 消