01 / 21

Using Matrices to
Represent & Manipulate Data

Learn how matrices organize real-world information: payoff tables, network connections, and more — then discover how matrix operations transform that data.

Precalculus

What Is a Matrix?

A matrix is a rectangular array of numbers arranged in rows and columns. We describe its size as \( m \times n \), where \( m \) is the number of rows and \( n \) is the number of columns.

3 7 1 0 5 2 4 8 6 Row 1 Row 2 Row 3 Col 1 Col 2 Col 3
\( 3 \times 3 \)
matrix

Why Use Matrices for Data?

Matrices let you compress entire tables of information into a single mathematical object you can add, subtract, and multiply — making it easy to analyze and transform complex data.

Payoff Tables
Store outcomes for each player/strategy combination in a game theory scenario.
Network Graphs
Represent which nodes are connected (adjacency matrices) in a communication or road network.
Inventory Data
Track quantities of products across multiple stores in one compact structure.

Key Vocabulary

1
Dimensions: An \( m \times n \) matrix has \( m \) rows and \( n \) columns.
2
Element / Entry: A single value \( a_{ij} \) inside the matrix.
3
Square Matrix: A matrix where \( m = n \). Required for adjacency matrices of simple graphs.
4
Scalar: A single number used to multiply every entry in a matrix.
5
Adjacency Matrix: A \(0/1\) matrix where entry \( a_{ij} = 1 \) means node \( i \) connects to node \( j \).

Core Matrix Operations

Three operations let you manipulate matrix data. Each has a clear rule about when it can be applied and what it produces.

Addition / Subtraction
Same-size matrices only. Add or subtract corresponding entries: \( (A \pm B)_{ij} = a_{ij} \pm b_{ij} \).
Scalar Multiplication
Multiply every entry by the scalar \( k \): \( (kA)_{ij} = k \cdot a_{ij} \).
Matrix Multiplication
Columns of \( A \) must equal rows of \( B \). Result entry: \( (AB)_{ij} = \sum_{k} a_{ik} b_{kj} \).

Addition: Entry by Entry

Two matrices can be added or subtracted only if they share the same dimensions. The operation pairs each entry with its counterpart in the other matrix.

1 3 2 4
\( + \)
5 7 6 8
\( = \)
6 10 8 12

Scalar Multiplication

Multiplying a matrix by a scalar \( k \) means scaling every single entry by that number. The matrix dimensions stay the same.

3
\( \cdot \)
2 4 1 5
\( = \)
6 12 3 15

Matrix vs. Scalar vs. Vector

Object Dimensions Example Use Case
Scalar \( 1 \times 1 \) \( 7 \) A single measurement
Row Vector \( 1 \times n \) \( \begin{bmatrix} 3 & 5 \end{bmatrix} \) One observation, many features
Column Vector \( m \times 1 \) \( \begin{bmatrix} 3 \\ 5 \end{bmatrix} \) Several observations of one feature
Matrix \( m \times n \) \( \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \) Full data table

Adjacency Matrices for Networks

An adjacency matrix encodes which nodes in a graph are connected. If node \( i \) connects to node \( j \), then \( a_{ij} = 1 \); otherwise \( a_{ij} = 0 \).

A B C D Adjacency Matrix A B C D A B C D 0 1 1 1 1 0 1 0 1 1 0 0 1 0 0 0

How to Build a Data Matrix

1
Identify categories. Decide what the rows represent and what the columns represent (players, stores, nodes, etc.).
2
Determine the dimensions. Count the categories: \( m \) rows and \( n \) columns give you an \( m \times n \) matrix.
3
Fill in entries. Place each data value in the correct row-column position.
4
Label clearly. Annotate rows and columns so the matrix is interpretable on its own.
5
Apply operations. Use addition, scalar multiplication, or matrix multiplication to answer questions about the data.

Example 1: Store Inventory

Two stores sell three products. Matrix \( A \) holds January sales and matrix \( B \) holds February sales. Find total sales \( A + B \).

A (Jan) P1 P2 P3 S1 S2 10 20 15 5 30 25
\( + \)
B (Feb) 8 15 12 7 10 20
\( = \)
A + B 18 35 27 12 40 45 S = Store, P = Product. Each entry = units sold.

Example 2: Payoff Matrix

In a two-player game, each cell holds the payoff for Player 1 given each combination of strategies. Positive means a gain; negative means a loss.

Player 1 Payoff Matrix Player 2 Rock Paper Player 1 Rock Paper 0
\( -1 \)
\( +1 \)
0

Example 3: Matrix Multiplication

A bakery has a \( 2 \times 3 \) quantity matrix \( Q \) (stores × items) and a \( 3 \times 1 \) price vector \( P \). The product \( QP \) gives total revenue per store.

Q (2×3) 5 10 8 3 7 12
\( \cdot \)
P (3×1) 2 3 4
\( = \)
QP (2×1) 72 75
\(5 \cdot 2 + 10 \cdot 3 + 8 \cdot 4\)
\(3 \cdot 2 + 7 \cdot 3 + 12 \cdot 4\)
$/item $/store

Dimension Compatibility Rule

Matrix multiplication \( A \cdot B \) is only defined when the number of columns in \( A \) equals the number of rows in \( B \).

\(m \times p\)
A
\( \cdot \)
\(p \times n\)
B
\( = \)
\(m \times n\)
AB must match

Common Mistakes

Wrong Dimensions
Adding matrices of different sizes: you can only add \( m \times n \) to \( m \times n \).
Assuming Commutativity
Thinking \( AB = BA \). Matrix multiplication is not commutative in general.
Entry-wise Multiplication
Multiplying corresponding entries instead of using the dot-product (row-by-column) rule.

Operations Summary

Operation Requirement Result Size Rule
\( A + B \) Same dimensions Same as \( A \) Add entry by entry
\( A - B \) Same dimensions Same as \( A \) Subtract entry by entry
\( kA \) Any matrix Same as \( A \) Multiply every entry by \( k \)
\( A \cdot B \) Cols of \( A \) = Rows of \( B \) \( m \times n \) Row-by-column dot product

Question 1 of 5

If \( A \) is a \( 3 \times 4 \) matrix and \( B \) is a \( 4 \times 2 \) matrix, what are the dimensions of \( AB \)?

Question 2 of 5

Given \( A = \begin{bmatrix} 2 & 5 \\ 1 & 3 \end{bmatrix} \) and \( B = \begin{bmatrix} 4 & 1 \\ 6 & 0 \end{bmatrix} \), what is entry \( (1,2) \) of \( A + B \)?

Question 3 of 5

A graph has 4 nodes. Its adjacency matrix is \( 4 \times 4 \) and symmetric. If the sum of all entries in row 1 is 3, how many edges connect to node 1?

Question 4 of 5

If \( C = \begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix} \), what is \( 3C \)?

Question 5 of 5

A store sells two items. The quantity matrix is \( Q = \begin{bmatrix} 4 & 6 \end{bmatrix} \) and the price vector is \( P = \begin{bmatrix} 3 \\ 5 \end{bmatrix} \). What is the total revenue \( QP \)?