Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.4K Views
|
7 Replies
|
3 Total Likes
View groups...
Share
Share this post:

[?] Factor out matrices in expressions?

Posted 8 years ago

Hi Community,

I am working on a tutorial for matrix algebra, I cannot figure out how to make Mathematica identify and replace previously defined symbols in calculations. For example. I have defined

rules = {IdentityMatrix[2] -> Subscript[\[Sigma], 0], 
  PauliMatrix[1] -> Subscript[\[Sigma], 1], 
  PauliMatrix[2] -> Subscript[\[Sigma], 2], 
  PauliMatrix[3] -> Subscript[\[Sigma], 3]}

So when I make

Grid[Join[{Table[PauliMatrix[i] // MatrixForm, {i, 3}]}, 
  Table[MatrixForm[PauliMatrix[i].PauliMatrix[j] /. rules], {i, 
    3}, {j, 3}]]]

I get Subscript[\[Sigma], 0] in the diagonal, but cannot figure out how I make Mathematica to identify the other elements as simply products of +/- I and the other Pauli matrices.

Or simpler put: how do I make Mathematica answer I PauliMatrix[3] to the input

PauliMatrix[1].PauliMatrix[2]

Kind regards

Mogens

Ps. Is it true that Solve etc. does not work on matrices, or is it just me? (I have tried to specify Matrices[{2,2},Complexes] as the domain but I get errors or nothing back)

POSTED BY: jallberg
7 Replies
Posted 8 years ago

Thanks David,

I will write you directly as you suggested, but for the sake of this thread I wanted to thank you for the good advice and try to clarify what I am looking for.

Example

I want to present to reader with a table of the product of the Pauli matrices like

Table[PauliMatrix[i].PauliMatrix[j] // MatrixForm, {i, 3}, {j, 
   3}] // Grid

I would go on to show the results in terms of the Pauli matrices as well, i.e.

Grid[{{s0, I s3, I s2}, {-I s3, s0, I s1}, {-I s2, -I s1, s0}}]

(with s0 being the 2x2 Identity matrix, and si the i'th Pauli matrix).

Clearly, I can do this by hand, but then I might as well work in a typesetting program (like LaTeX). Also as I advance to to work on Dirac's Gamma matrices, (anti-)commute relations, contractions and such, it would be helpful to have Mathematica recognise e.g. that [s1,s2] = 2 I s3 without necessary being aware of it myself.

The "magic" command would be something like ExpressInTermsOf[myExpression,myFavoriteMatrixList], looking in myExpression for possible ways to rewrite it using the elements in myFavoriteMatrixList.

So I am very curious to see what your FactorOut does.

/Mogens

POSTED BY: jallberg
Posted 8 years ago

In fact, giving it a little more thought, this is a rather general request. There are numerous situations where you would want to reduce your expressions by substituting parts of them by named (sub-)expressions, or rather: where you would want to use Mathematica to explore the possibility too see if it leads to a simpler result. Using the above example with

a = x+3

rewriting x+4 as a+1 or identify Exp[3] Exp[x] as Exp[a] are just a couple of other situations.

So I search for a way to tell Mathematica to look for certain patterns that I provide in an expression, and show what the expression would look like if the pattern were to be "eliminated". I realise that in some instances this would require a hand-held effort on my side, because the would be ambiguities, but in the example with the Pauli Matrices I think is pretty straight forward.

Hope some of you experienced users can point me in the right direction.

/Mogens

POSTED BY: jallberg
Posted 8 years ago

Thanks Daniel,

What I meant was, can I make Mathematica recognise PauliMatrix[1].PauliMarix[2] as I PauliMatrix[3]? So rather than answer {{I, 0}, {0, -I}} it would say I PauliMatrix[3] (and ultimately use the sigma symbols I have defined)?

I guess it would be similar in simpler expressions. Suppose I defined

a = x+3

how would I make Mathematica reduce

x^2 + 9 + 6x

to

a^2

?

POSTED BY: jallberg

You should understand that evaluation in the Wolfram Language means something like I PauliMatrix[3] will automatically become an explicit matrix {I, 0}, {0, -I}}. There are ways to preclude this using Hold but they are more trouble than they are worth. An alternative route might be to work with your own purely symbolic pauliMatrix (note lower casing of first word, to distinguish from the built-in function). When you want to do symbolic manipulations you might use NonCommutativeMultiply as operator, and only when you want to convert to explicit matrices do you use substitutions such as {NonCommutativeMultiply->Dot,pauliMatrix->PauliMatrix}.

Also for the purpose at hand you might want to consider introducing a commutator, so that the comcommutative products can be "canonicalized" prior to using a substitution such as this: pauliMatrix[1] ** pauliMatrix[2] -> I*pauliMatrix[3]. One way to go about this is shown here.

https://www.researchgate.net/publication/262223580_Symbolic_FAQ

See the section "Some noncommutative algebraic manipulation", in particular the example that defines and uses a function called ncTimes.

POSTED BY: Daniel Lichtblau
Posted 8 years ago

Thanks again Daniel,

It really is a shame! I had hoped Mathematica would be smart enough to recognise, say, that some matrix was actually the product of an integer and the identity matrix and such; especially if I hinted it by saying "look for multiples of the identity marix" somehow. Can't be far off in the future with a bit of machine learning though.

Great link - there are lots of useful information there. I had started on commute and anti-commute functions but this helps me leap forward.

/Mogens

POSTED BY: jallberg

PauliMatrix[1].PauliMatrix[2] and I PauliMatrix[3] evaluate to the same matrix.

In[1119]:= {PauliMatrix[1].PauliMatrix[2], I PauliMatrix[3]}

(* Out[1119]= {{{I, 0}, {0, -I}}, {{I, 0}, {0, -I}}} *)

Given that, it is quite unclear what is wanted here.

On a separate note, you are correct that Solve does not work with the Matrices[...] domains (It works fine with explicit matrices but that is not the same thing).

POSTED BY: Daniel Lichtblau
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard