# Multiply two matrices?

Posted 2 months ago
413 Views
|
5 Replies
|
1 Total Likes
|
 Hey folks! New kid on the block and working with matrices I have two matrices: a = {{1, 4, -2}, {3, 5, 2}} b = {{6}, {-1}, {3}}The second matrix should be a 3 row, 1 column. If I try to multiply the 2, I get an error :Thread::tdlen: Objects of unequal length in {{1,4,-2},{3,5,2}} {{6},{-1},{3}} cannot be combined.As I said, I'm new at this, matrix operations are still "magic" and I suspect I entered the 1 column matrix wrong...but, I don't see the error in my ways....Can someone please show me what I did wrong?The result should be a single column, 2 row with -4 and 19 as the elements...Thanks in advance!Tim
5 Replies
Sort By:
Posted 2 months ago
 a = {{1, 4, -2}, {3, 5, 2}}; b = {6, -1, 3}; a.b gives {-4, 19} Mathematica can usually interpret a vector as either a row or a column as needed
Posted 2 months ago
 Why a "dot" function instead of multiplication?Hate to sound stupid but how can it know that I actually needed a 1 column instead of the 3 columns as you listed? Or did I miss something?I'm absolutely new to this, never had math beyond high school and that really didn't touch Calculus...and we didn't cover matrices either (high school class of 1972....we actually got to use a slide rule in my senior year).I am totally amazed at what this software can do...and I haven't even begun to dig in...Thanks!Tim
Posted 2 months ago
 Did a bit of research....Mathematica apparently doesn't treat matricies in the same way our minds do....and therefore the "dot" operator is more appropriate.....I have SO much to learn...
 Mathematica apparently doesn't treat matricies in the same way our minds do.... No, this should not become an esoteric topic! A multiplication of numbers and a multiplication of matrices are two totally different things! Here an example: m1 = {{a, b}, {c, d}}; m2 = {{d, e}, {f, g}}; m1 m2 (* element wise multiplication *) (* Out: {{a d,b e},{c f,d g}} *) m1.m2 (* matrix multiplication *) (* Out: {{a d+b f,a e+b g},{c d+d f,c e+d g}} *)