[Mathematica] Ordered matrix multiplication

Click For Summary
SUMMARY

This discussion focuses on performing ordered matrix multiplication using Mathematica. The user aims to apply the MatrixExp function to a list of square matrices and multiply them in reverse order due to non-commutativity. The solution provided involves using the Dot function combined with MatrixExp and Reverse to achieve the desired result efficiently. The final one-liner solution is M=L1//MatrixExp/@#&//Reverse//Dot@@#&.

PREREQUISITES
  • Familiarity with Mathematica syntax and functions
  • Understanding of matrix operations, specifically matrix exponentiation
  • Knowledge of non-commutative properties of matrix multiplication
  • Experience with functional programming concepts in Mathematica
NEXT STEPS
  • Explore advanced matrix operations in Mathematica, focusing on non-commutative multiplication
  • Learn about the performance implications of using MatrixExp on large matrices
  • Investigate alternative methods for matrix multiplication in Mathematica
  • Study the use of functional programming techniques in Mathematica for efficient data manipulation
USEFUL FOR

This discussion is beneficial for mathematicians, physicists, and software developers working with linear algebra in Mathematica, particularly those dealing with non-commutative matrix operations.

guerom00
Messages
90
Reaction score
0
Hello everyone,

I have a list, let's call it L1, of length N. Each element of this list is a square matrix.
I would like to :
1/ Apply MatrixExp[] to each element of L1 (I know how to do that)
2/ Multiply each element of the subsequent list _in an ordred fashion_ i.e. from element N to element 1. In this order (!) because none of the matrices commute.

To recap, I have

L1={L1[[1]],L1[[2]],...,L1[[N]]}

and want the matrix M equal to

M=MatrixExp[L1[[N]]].MatrixExp[L1[[N-1]]]...MatrixExp[L1[[1]]]

What would be a nice "one liner" which does that ?
Thanks in advance :)
 
Physics news on Phys.org
This isn't elegant...
First create an example list of 5 random 2x2 matrices
(working symbolically would be very slow)
In[1]:= l[i_][__]:=-Random[]
In[2]:= L[i_]:=Array[l,{2,2}]
In[3]:= LL=Array[L,5];

Now combine them together the way you wanted:
In[4]:= MatrixExp[Dot@@(MatrixExp/@Reverse[LL])]
Out[4]= {{1.12427,-0.100453},{-0.206832,1.17472}}

Note that for very many large matrices, you might want to use a different solution that does not have to store each element in MatrixExp/@Reverse[LL].
 
Thanks for your message :)
Yeah, I ended up doing more or less what you suggested. I wrote M=L1//MatrixExp/@#&//Reverse//Dot@@#&.
That was the Dot part I wasn't sure about : I thought for some reason that Dot[] accepted only two arguments. But no... It nicely "threads" over any number of arguments :)
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 13 ·
Replies
13
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 22 ·
Replies
22
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K