0

Say I give something like AB+AB+BA to matlab (or mupad), and ask it to simplify it. the answer should be: 2AB+BA. Can this be done in matlab or mupad?

Edit:

Ok, this is feeling rediculous. I'm trying to do this in either matlab or mulab, and.. it's frustrating not knowing how to do what should be the simplest things, and not being able to find the answers right away via google.

I want to expand the following, multiplied together, as a taylor series:

eq1 := exp(g*l*B):
eq2 := exp(l*A):
eq3 := exp((1-g)*l*B):

g is gamma, l is lambda (don't know how to represent either of these in matlab or mulab). A and B don't commute. I want to multiply the three exponentials together, expand, select all terms of a given power in lambda, and simplify the result. Is there a simple way to do this? or should I give up and go to another system, like maple?

juggler
  • 319
  • 1
  • 5
  • 16
  • Are all of the variables scalars? When you say "`A` and `B` don't commute", do you mean in addition, multiplication, everything? – horchler Jan 28 '14 at 21:32
  • these are exponential operators that will operate on a wave-function. A is related to the laplacian, (second spacial derivative), B to the potential. that help? – juggler Jan 29 '14 at 14:35

1 Answers1

1

This is mupad, not matlab:

operator("x", _vector_product, Binary, 1999):
A x B + A x B + B x A

returns

2 A x B + B x A

The vetor product is used, simply because it matches the described requirements.

Daniel
  • 36,610
  • 3
  • 36
  • 69
  • 1
    Nice. Note however that the [vector product is also not associative](http://en.wikipedia.org/wiki/Cross_product) -not sure what the OP wants. @juggler: You can evaluate this from within Matlab using `evalin(symengine,...)`, e.g., `evalin(symengine,'operator("x", _vector_product, Binary, 1999)');` `evalin(symengine,'AxB+AxB+BxA')`. – horchler Jan 28 '14 at 21:27