Mathematica 8.0 - Generating List of Powers of Matrices/Graphs

In summary, the conversation revolved around trying to consider matrix powers of a Wielandt matrix of order n in order to find minimal scrambling and regularity indices. The first issue was how to display the matrices in a table form without losing the matrix brackets, which was achieved by using TableForm[Table[MatrixForm[MatrixPower[A, k]], {k, 5}]]. The second issue was how to convert all nonzero values in the matrices to 1, which was done by using a for loop and then incorporating it into the table of matrices. Finally, the goal was to turn these matrices into adjacency graphs, which was achieved by using the AdjacencyGraph function. The conversation ended with the expert summarizer thanking the original
  • #1
IBeBananaMan
2
0
Hello.

I'm trying to consider a matrix A and looking at Ak and (Ak)TAk, where T is the usual transpose.

This is no big deal. But I'd rather not look at them one at a time--I want to consider some powers k from 1 through as high as I want them. When I try

Code:
Table[MatrixPower[A, k],{k,5}]//MatrixForm

it gives me this giant matrix of each matrix I want, sure, but the matrices are all broken up into column vectors. How can I fix this so I can get a good table of separated matrices (changing MatrixForm to TableForm gives me the view I want, but the matrix brackets are gone so it's just a generic tableau).

Now that's the first issue. My next issue is I would like to take every nonzero element in each matrix and turn it into the value 1.

For just one matrix, I have this

Code:
For[i = 1, i < n + 1, i++,
  For[j = 1, j < n + 1, j++,
   If[MatrixPower[A, k][[i, j]] == 0, AAl[i, j] := 0, 
    AAl[i, j] := 1]]];

Which gives me what I want (the matrix Ak will have nonnegative integers for what I'm dealing with, so I can just look for the 0s of my Ak and force every other element = 1). But I'd like to incorporate that into my table of all matrices so I can compute this for all powers simultaneously (it doesn't matter if, say, Ak's values are 0s and 1s and then the next Ak+1 is computed from the modified Ak instead of from the original Ak).

Finally, I'd like to turn all these into adjacency graphs and thus see how the adjacency graph changes with each power. From the above, I simply do

Code:
AA := Table[AAl[i, j], {i, n}, {j, n}];

to create the matrix from the values of the for loop and then finally

Code:
AdjacencyGraph[AA, VertexLabels -> "Name", ImagePadding -> 10]

to see the adjacency graph, and obviously this only works for one matrix power at a time.

Any help would be appreciated. And if there is a better way of dealing with this (I just assume I HAVE to convert my nonzero values to 1 for Mathematica to spit out any adjacency matrix), that would be appreciated.

For reference, I'm looking at Wielandt matrices of order n (which I fix, and I will look at one order at a time), and I'm trying to look at the pattern of the adjacency graphs for finding minimal scrambling and regularity indices (which are the exponents k).

Thanks!
 
Physics news on Phys.org
  • #2
Code:
TableForm[Table[MatrixForm[MatrixPower[A, k]], {k, 5}]]
and
Code:
tabs = Table[MatrixPower[A, k], {k, 5}]
newtable=TableForm[Table[MatrixForm[Table[tabs[[i]][[j, k]] /. {a_ :> If[a == 0, 0, 1]}, {j, 1, Length[A]}, {k, 1, Length[A]}]], {i, 1, Length[tabs]}]]

getting rid of the matrixform and tableform when you need to do actual calculations.
 
  • #3
Wow, thanks a bunch! Not only did you do it, but by replacing MatrixForm with AdjacencyGraph in your second code gives me the graphs I'm looking for (typing this for reference in case anyone else is fooling around with adjacency graphs/matrices). Problem solved!
 
  • #4
No problem! I'm sorry I wasn't able to type up more, it was late at night and I was distracted watching a movie, and figured you knew enough that you'd be able to figure out what I did!
 
  • #5


Dear researcher,

Thank you for sharing your current project with us. It seems like you are using Mathematica 8.0 to generate a list of powers of matrices and graphs. It is great to see you are exploring different ways to analyze your matrices and find patterns in the adjacency graphs.

Regarding your first issue, it seems like you are trying to generate a table of matrices in a specific format. To do this, you can use the command "ArrayReshape" to reshape your matrix into a desired format. For example, if you want to reshape each matrix into a 2x2 format, you can use the command "ArrayReshape[MatrixPower[A, k], {2, 2}]". This will give you a table of matrices in a 2x2 format. You can change the dimensions to fit your needs.

For your second issue, instead of using a for loop, you can use the "Map" function to apply a function to each element in a matrix. For example, you can use "Map[If[# == 0, 0, 1]&, MatrixPower[A, k], {2}]" to change all the nonzero elements to 1 in each matrix. This will give you a table of matrices with all nonzero elements turned into 1.

Finally, to create adjacency graphs for each matrix power, you can use the "Map" function again to apply the "AdjacencyGraph" function to each matrix in your table. This will give you a table of adjacency graphs, each corresponding to a specific matrix power.

I hope these suggestions will help you in your project. If you need any further assistance, please do not hesitate to reach out. Keep up the great work in exploring the patterns in your matrices and graphs!
 

1. How do I generate a list of powers of matrices in Mathematica 8.0?

To generate a list of powers of a matrix in Mathematica 8.0, you can use the MatrixPower function. This function takes two arguments - the matrix you want to raise to a power and the power you want to raise it to. For example, the code MatrixPower[A, 3] will generate a list of powers of matrix A up to the 3rd power.

2. Can I generate a list of powers of graphs in Mathematica 8.0?

Yes, you can generate a list of powers of graphs in Mathematica 8.0 using the GraphPower function. This function works in a similar way to MatrixPower, taking a graph as the first argument and the desired power as the second argument. For example, the code GraphPower[G, 4] will generate a list of powers of graph G up to the 4th power.

3. How do I specify the size of the list when generating powers of matrices/graphs in Mathematica 8.0?

To specify the size of the list when generating powers of matrices or graphs in Mathematica 8.0, you can use the Table function. This function allows you to specify the number of iterations you want to perform, and you can use it in combination with MatrixPower or GraphPower to generate a list of powers of a matrix or graph of a specific size.

4. What is the benefit of generating a list of powers of matrices/graphs in Mathematica 8.0?

Generating a list of powers of matrices or graphs in Mathematica 8.0 can be useful for various purposes, such as analyzing trends or patterns in the powers, performing calculations on a large number of powers at once, or generating a visual representation of the powers using built-in graphing functions in Mathematica.

5. Can I use variables instead of specific matrices/graphs when generating powers in Mathematica 8.0?

Yes, you can use variables instead of specific matrices or graphs when generating powers in Mathematica 8.0. This can be useful when you want to perform the same operation on multiple matrices or graphs without having to specify each one individually. You can also use variables in combination with Table to generate a list of powers for different values of the variables.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Replies
1
Views
508
Replies
9
Views
942
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
3K
  • Calculus and Beyond Homework Help
Replies
1
Views
673
Back
Top