Message Boards Message Boards

0
|
11707 Views
|
7 Replies
|
5 Total Likes
View groups...
Share
Share this post:

[?] Multiply more than 2 matrices?

Posted 7 years ago
Attachments:
POSTED BY: Tracy Borne
7 Replies
Posted 7 years ago
POSTED BY: Tracy Borne
POSTED BY: Gianluca Gorni
Posted 7 years ago

Try this, and notice each of the subtle changes made to your code,

B = {{(y - 10)/100, 0, (10 - y)/100, 0, y/100, 0, -y/100, 0},
     {0, (x - 10)/100, 0, -x/100, 0, x/100, 0, (10 - x)/100},
     {(x-10)/100, (y-10)/100, -x/100, (10-y)/100, x/100, y/100, (10-x)/100, -y/100}};
M = {{10666.67, 2666.67, 0}, {2666.67, 10666.67, 0}, {0, 0, 4000}};
Q = Transpose[B].M.B;
Integrate[Q, {x, 0, 10}, {y, 0, 10}]

which returns this

{{4888.89, 1666.67, -2888.89, -333.333, -2444.45, -1666.67, 444.445, 333.332},
 {1666.67, 4888.89, 333.332, 444.445, -1666.67, -2444.45, -333.333, -2888.89},
 {-2888.89, 333.332, 4888.89, -1666.67, 444.445, -333.333, -2444.45, 1666.67},
 {-333.333, 444.445, -1666.67, 4888.89, 333.332, -2888.89, 1666.67, -2444.45},
 {-2444.45, -1666.67, 444.445, 333.332, 4888.89, 1666.67, -2888.89, -333.333},
 {-1666.67, -2444.45, -333.333, -2888.89, 1666.67, 4888.89, 333.332, 444.445},
 {444.445, -333.333, -2444.45, 1666.67, -2888.89, 333.332, 4888.89, -1666.67},
 {333.332, -2888.89, 1666.67, -2444.45, -333.333, 444.445, -1666.67, 4888.89}}

Perhaps the documentation wasn't quite clear enough. Applying MatrixForm to an expression does make it perhaps cute to look at, but gives a result which is, roughly, no longer able to be used for any subsequent calculations. If you need cute and and subsequent calculations then you can insert an extra line like this

Print[MatrixForm[Q]];

which will not change the value of Q but will display a formatted result.

And, as with everything in Mathematica, there are always a dozen different ways of accomplishing the same thing. Pick one that you can remember and use without making too many mistakes and stick with it.

POSTED BY: Bill Simpson
Posted 7 years ago

Thank you for your responses. My apologies - I am new here and did try posting the code, but it didn't copy and paste clearly likely because I was trying to show the output as well. I was able to get the matrix multiplication to work, but only after scrapping the entire file and starting over. Now I cannot seem to get a double integration of the resulting matrix to evaluate. The output shows more like a restatement of the problem, and still has variables in the matrix when it should be numerical (they are definite integrals). I am posting the code below, but also attaching a picture so that you can see my results.

Clear [x, y]

Clear [B]

B = ( {
    {(y - 10)/100, 0, (10 - y)/100, 0, y/100, 0, -y/100, 0},
    {0, (x - 10)/100, 0, -x/100, 0, x/100, 0, (10 - x)/100},
    {(x - 10)/100, (y - 10)/100, -x/100, (10 - y)/100, x/100, 
     y/100, (10 - x)/100, -y/100}
   });

Clear [M]

M = ({
    {10666.67, 2666.67, 0},
    {2666.67, 10666.67, 0},
    {0, 0, 4000}
   });

Clear [Q]

Q = Transpose[B].M.B // MatrixForm

Integrate[Q, {x, 0, 10}, {y, 0, 10}]
Attachments:
POSTED BY: Tracy Borne

You can learn the best practices on using forum here: http://wolfr.am/READ-1ST

POSTED BY: Moderation Team
Posted 7 years ago

Please post code rather than a picture (and you're likely to get more and better help). Also, it would be good if you could show what didn't seem to work when you multiplied the three matrices.

POSTED BY: Jim Baldwin

Check the documentation on MatrixForm. Also it is regarded as good practice to post actual code rather than a picture of code. In case anyone wants to cut-and-paste it for experimenting, say.

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

Group Abstract Group Abstract