It's possible you can get decent results just by sorting the dot
products before converting to multiplication, like (<e1, e1>*<e0, e1>
=> <e0, e1>*<e1, e1>).
I'm more worried about the order in the dot products themselves. You
could sort within the dot products themselves, like <e1, e0> => <e0,
e1>, but you might still run into problems, e.g., <e0, e1> + <e1, e2>
won't combine. Most likely the safest bet is that whatever you used to
generate your expression put the dot products in the order they should
be for the best simplification. And of course, if you are dealing with
complex inner products, you probably just want the expression with no
conjugates (since <a, b> + conjugate(<a, c>) doesn't really simplify
anyway).
It's not possible to have a*b*c*d = c*d*a*b but not a*b = b*a. The way
noncommutativity works is that it is defined on symbols. Each product
of terms pulls out the "commutative part" (everything with
commutative=True) to the front, and then keeps the rest, the
noncommutative part, in the order it was created in. For example:
In [27]: var('a')
Out[27]: a
In [28]: var("A B", commutative=False)
Out[28]: (A, B)
In [29]: A*a*B
Out[29]: a⋅A⋅B
There have been discussions in the past on being able to represent
more complex commutation relationships. But even if that were
implemented, you would need some algorithms for simplifying
expressions.
Aaron Meurer
>
https://groups.google.com/d/msgid/sympy/8b71de13-95d8-410d-9f1e-d73f3c555aac%40googlegroups.com.