Message Boards Message Boards

GROUPS:

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
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

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

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}}  *)

Yes, the multiplication is different....however, what I see as a 3 row, single column matrix, Mathematica doesn't see it the same way. It treats it the same but I can't define it as I would expect and the software make use of it....so, it doesn't treat them the same way as at least MY mind does. Not meaning it isn't right, its just something I need to keep in mind.

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