Re: overloading times operator
- To: mathgroup at smc.vnet.net
- Subject: [mg88829] Re: overloading times operator
- From: Michael Weyrauch <michael.weyrauch at gmx.de>
- Date: Sat, 17 May 2008 23:29:01 -0400 (EDT)
- References: <g0m918$3n$1@smc.vnet.net>
- Reply-to: michael.weyrauch at gmx.de
Hello,
I really recommend to use NonCommutativeMultiply[] for a non-
commutative product and give it the desired properties (or any other
operator without built-in properties). Overloading Times[]
is potentially breaking Mathematica internals, which is probably the
reason for your strange results.
But I cannot further comment on your problem until you give a precise
definition of your non-commutative product. (In any case, if you use
NonCommutativeMultiply for your produvt, you also must define
NonCommutativeExpand separately.)
Michael Weyrauch
gstaples schrieb:
> I wrote a procedure to define the non-commutative product of two elements of the form e_X e_Y, where X and Y are multi-indices. I do this using Times.
>
> I do a simple calculation like
>
> Expand[(e_{1} + e_{3})(e_{1} - e_{3})]
>
> and get the wrong answer. (On the first try.)
>
> If I then re-execute the code that defines the multiplication, I repeat the calculation and get correct output.
>
> Alternatively, if I execute
>
> e=Symbol["e"]
>
> before loading the procedure, I get correct output on the first try.
>
> More troubling is that after getting correct output, if I perform calculations of a different kind (e.g. matrix multiplication), when I repeat my original calculation, I start getting incorrect output again. (Until I re-execute the code that defines the multiplication.)
>
> It's frustrating to repeat a calculation and get different sets of output depending on what other calculations are done in between.
>
> Does anyone have suggestions?
>