Mathematica:Matrix Multiplication of five 6x6 matrices

In summary, Bill Simpson suggests that you try multiplying matrices using the dot operator and the . symbol, and if that fails, try using the matrix form. If neither of those work, he suggests solving the equations for βex and sf.
  • #1
parazit
75
3
Hi,
I have five 6x6 matrices defined on mathematica with some unknowns and I need the final matrix let's say, mf.

When I tried to find out mf with Dot[] command, it works but the result won't be so logic. On the other hand, when I tried to do this multiplication with . symbol, there exists a result but when I asked the program let's say mf[[1,1]] it prints the entire row.

Lets say my matrices are m1,m2,m3,m4 and m5.( Notation is just for assumption)

What should I do to calculate if mf is written like following on the paper;
mf=m1.m2.m3.m4.m5

I tried a way like this also,

aa=m5.m4;
bb=aa.m3;
cc=bb.m2;
mf=cc.m1;

However, this is not logic. There sould be some way to define more than 2 matrices multiplication in one time.

If you need or request, I can upload my studies too.

Best.
 
Physics news on Phys.org
  • #2
What do you mean by so logic? Can you attach an example mathematica file?

for me m1.m2.m3 works fine. Or try m1.(m2.m3) to force order of operations.
 
  • #3
I mean the result is not so useful for further calculations.

I am trying to calculate the sf value that shown on the Dsf matrix. To do that I need to multiply that five 6x6 matrice and than use the Ts[[1,2]]=0 and Ts[[3,4]]=0 statements to find βex. After that, I can calculate sf. βex also sf must be some meanfull result compared to the reference values.

For example, If I take βin=βex=0 than ψin=ψex=0.001939 rad and than alpha will be 90 degree which is also 1.57 rad. From there,ρ will be 0.075 m. The other variables will not change. Than when I made the calculations I got sf as positive and negative two values however it should have a single, small, positive value.

I am so so confused even this is just a simple problem...
 

Attachments

  • multiplication.nb
    6.4 KB · Views: 537
  • #4
Ts = Dsi.Medgein.Mbody.Medgeex.Dsf // MatrixForm

is not doing a matrix multiply
then assigning that matrix to TS
THEN changing the result into MatrixForm to display it.

Instead it
is doing a matrix multiply
then changing the result into MatrixFormwhich is different from a matrix
THEN assigning that to to Ts and finally displaying that.

Instead of this
Ts = Dsi.Medgein.Mbody.Medgeex.Dsf // MatrixForm
Ts[[1, 2]]
Ts[[3, 4]]
do this
Ts = Dsi.Medgein.Mbody.Medgeex.Dsf;
Ts // MatrixForm
Ts[[1, 2]]
Ts[[3, 4]]

See if your results are meaningful after this change
 
  • #5
Thank you Bill Simpson, it worked for the matrix multiplication.

Then I tried to solve the rest that I mentioned. If you don't mind please share the results if it's possible. I would like to compare them with mine and try to find a way.

Thank you.
 
  • #6
Using your multiplication.nb notebook that you posted with this small change:
...
Ts = Dsi.Medgein.Mbody.Medgeex.Dsf
Ts // MatrixForm
Ts[[1, 2]]
Ts[[3, 4]]
FindRoot[{Ts[[1, 2]] == 0, Ts[[3, 4]] == 0}, {{βex, 0}, {sf, 1}}]

returns

{βex -> 0.135322, sf -> -0.258422}

Since you have trig functions there will be many solutions for βex.

For example, this shows the repeating solutions for both equations for repeating values of βex given a fixed value for sf:

Plot[Evaluate[{Ts[[1, 2]], Ts[[3, 4]]} /. sf -> -0.2584215664919408], {βex, -2 Pi, 2 Pi}]

I have not explored whether there are other values of sf which yield solutions, but I would not be surprised if there were whole parametric curves for values of {βex, sf} that are solutions to your pair of equations.

Note: It is dangerous and error prone to not use a semicolon between each expression in a notebook. Sometimes you can do this and still have it work. But this has been a source of difficult to track down errors for many years. I suggest ending each expression in your notebook with a semicolon and using Print[] if you need to have an expression displayed when evaluating a notebook.
 
Last edited:
  • #7
Bill Simpson,
Thank you so much for your advise and help. I know that the function is periodic but actually expect a small value for βex and also a small value for sf since the final result which I have to reach is multiplication of Ts[[1,1]] and 0.01 must be a positive and really really small number.

I will check the whole code today and rewrite it in a form that you mentioned. Also I will add some notes that indicates the meaning of each value.

Thank you so much for your kind and helpfull messages.

 

1. How do I multiply five 6x6 matrices in Mathematica?

To multiply five 6x6 matrices in Mathematica, you can use the Dot function. For example, if your matrices are named A, B, C, D, and E, the command would be A.B.C.D.E.

2. Can I use the MatrixForm function to display the result of the multiplication in a more readable format?

Yes, you can use MatrixForm to display the result in a more readable format. Simply wrap the Dot function with MatrixForm. For example, MatrixForm[A.B.C.D.E].

3. Is there a limit to the number of matrices that can be multiplied in Mathematica?

No, there is no limit to the number of matrices that can be multiplied in Mathematica. However, as the number of matrices increases, the computation time may also increase.

4. Can I multiply matrices with different dimensions in Mathematica?

Yes, you can multiply matrices with different dimensions in Mathematica. However, the number of columns in the first matrix must be equal to the number of rows in the second matrix.

5. How do I check if the multiplication of matrices was successful in Mathematica?

To check if the multiplication of matrices was successful, you can use the Dimensions function. If the resulting matrix has the dimensions of a 6x6 matrix, then the multiplication was successful. You can also use MatrixQ to check if the result is a valid matrix.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Programming and Computer Science
Replies
5
Views
1K
  • Linear and Abstract Algebra
Replies
1
Views
946
  • Precalculus Mathematics Homework Help
Replies
6
Views
2K
Replies
3
Views
258
Replies
6
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Replies
1
Views
1K
  • Linear and Abstract Algebra
Replies
5
Views
1K
  • Calculus and Beyond Homework Help
Replies
19
Views
8K
Back
Top