77.4k views
4 votes
Create a function that takes two matrices and returns a new one matrix which is their product.

• The main program must give two matrices and display the result of their multiplication.

User Krtko
by
8.4k points

1 Answer

2 votes

Final answer:

To multiply two matrices, you need to use the dot product of rows from the first matrix and columns from the second matrix. Here is an example.

Step-by-step explanation:

When multiplying matrices, we need to use the dot product of rows from the first matrix and columns from the second matrix. The resulting matrix will have dimensions equal to the number of rows from the first matrix and the number of columns from the second matrix.

Here is an example:

Let's say we have two matrices:

[1 2 3]
[4 5 6]

and

[7 8]
[9 10]
[11 12]

To find their product, we multiply the rows of the first matrix by the columns of the second matrix:

(1 * 7) + (2 * 9) + (3 * 11)
(1 * 8) + (2 * 10) + (3 * 12)

4 * 7 + 5 * 9 + 6 * 11
4 * 8 + 5 * 10 + 6 * 12

User Starlene
by
7.5k points