Recent chats

How do I calculate one entry of a matrix product without losing track of rows and columns?

Quick answer

To find entry (i, j) of AB, take row i of A and column j of B. Multiply their entries in matching positions, then add those products. Keep the row and column labels visible until the sum is finished. For the complete product, repeat this for each output position; the number of columns in A must equal the number of rows in B.

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I keep mixing up which row and column to use. What is the rule for just one entry?

Geez

For the entry in row i and column j of AB, pair row i of A with column j of B. Multiply the first entries together, the second entries together, and so on; add those products. The row number chooses from the first matrix, and the column number chooses from the second. This is the row-by-column rule. [S1]

A handy label is “output (row, column) = A’s row × B’s column.” Keep that label beside the calculation so the chosen row or column does not change midway. The matrices must also have compatible inner dimensions: A’s column count must match B’s row count, so every position in the selected row has a partner in the selected column.

Follow-up question

Can you show one calculation with actual numbers and make the matching positions obvious?

Geez

Use these illustrative matrices: A = [ [-1, 2, 3], [4, 0, 5] ] B = [ [5, -1], [-4, 0], [2, 3] ]

Suppose you want entry (1, 2) of AB. The selected row is row 1 of A: (-1, 2, 3). The selected column is column 2 of B: (-1, 0, 3). Align them by position:

A row 1: -1 2 3 B column 2: -1 0 3 Products: 1 0 9

Add the products: (-1)(-1) + (2)(0) + (3)(3) = 1 + 0 + 9 = 10. So the entry in row 1, column 2 of AB is 10. The important point is that “matching” means same position within the selected row and column, not the same row or column number in both matrices.

Follow-up question

How do I carry that through to the whole product without skipping an entry?

Geez

A is 2 × 3 and B is 3 × 2, so the product has 2 rows and 2 columns. Work across one row of A at a time, and use each column of B for the entries in that output row.

For row 1 of A, (-1, 2, 3): (1, 1): (-1)(5) + (2)(-4) + (3)(2) = -5 - 8 + 6 = -7. (1, 2): (-1)(-1) + (2)(0) + (3)(3) = 10.

For row 2 of A, (4, 0, 5): (2, 1): (4)(5) + (0)(-4) + (5)(2) = 30. (2, 2): (4)(-1) + (0)(0) + (5)(3) = 11.

Therefore AB = [ [-7, 10], [30, 11] ]. This product is also shown in the cited lesson. [S1] As a simple placement check, the first number in each calculation goes in the output row and column named by its label. The cited example supports this calculation method and result; it does not establish a shortcut for other matrix operations.

Follow-up question

What can I write on paper as a repeatable template, and what should I check if my answer seems wrong?

Geez

Use this copyable layout for each output entry:

Output (__, __): Selected row of A: (__, __, ...) Selected column of B: (__, __, ...) Matching products: (__×__) + (__×__) + ... Sum: __

Fill in the output label before doing arithmetic. Then check that you copied the requested row and column correctly, used every position once, and added signed products carefully. If an output entry is in row 2, column 1, it must come from row 2 of A and column 1 of B. Finally, confirm the output shape: its row count comes from A and its column count comes from B. These checks help catch bookkeeping slips; they do not replace checking the arithmetic.

A practical checklist

  • Confirm that A’s number of columns equals B’s number of rows.

  • Label the output position (row, column) before selecting entries.

  • Copy that row from A and that column from B in order.

  • Multiply entries in matching positions, then add the signed products.

  • Place the sum in the labeled output position and check the final shape.

A few more useful answers

Why does the product have the same row count as A and column count as B?

Each output row is associated with a row of A, and each output column with a column of B. In the example, A is 2 × 3 and B is 3 × 2, so AB is 2 × 2.

Do I multiply entries across a row of A by entries across a row of B?

No. For AB, choose a row of A and a column of B. Pair their entries in order, multiply each pair, and add the results.

What if the number of columns in A does not match the number of rows in B?

Then the row and column entries cannot be paired all the way across, so AB is not defined. Check the dimensions before calculating.

Sources

References used for this guide.

  1. [S1] OpenStax Algebra and Trigonometry: Computing Product Entries Row by Column
    openstax.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work