MATH 250 · Mathematics for Economics II
Vectors and Matrices
Vectors and matrices let you handle dozens of prices, quantities and equations as single objects.
Key takeaways
- A vector is an ordered list of numbers; in economics it is often a bundle of goods or a list of prices.
- A matrix is a rectangular table of numbers with rows and columns, described by its size, such as 2 × 3.
- You add vectors and matrices entry by entry, and you scale them by multiplying every entry.
- The dot product multiplies matching entries and adds them up; revenue is the dot product of prices and quantities.
- Matrix multiplication needs the inner sizes to match, and unlike ordinary numbers, the order matters: AB is usually not BA.
Picture Maya, who runs a smoothie cart, at the end of a busy Monday. She sold 10 strawberry smoothies, 20 mango smoothies and 5 green ones. The prices are $4, $5 and $6. How much money did she make? You can do it in your head: 40 plus 100 plus 30, which is $170. But now picture a company with 5,000 products, 300 stores and 52 weeks. Nobody adds that up by naming each number. You need a way to treat a whole list, or a whole table, of numbers as one thing.
That is what vectors and matrices do. They are not new mathematics so much as good bookkeeping, a notation that lets one short line stand for a huge pile of arithmetic. Economists use them constantly: to describe bundles of goods, to link industries together, and to write down systems of equations. This lesson builds the vocabulary. The next lessons, Solving Linear Systems With Matrices and Determinants, Inverses and Cramer's Rule, put it to work.
Vectors: lists with an order
A vector is a list of numbers written in a fixed order. Maya's Monday sales form the vector q = (10, 20, 5): strawberry first, mango second, green third. The order matters. (20, 10, 5) would describe a different day. Each number is called an entry or a component, and the number of entries is the vector's dimension. This one has dimension 3.
A vector can be a bundle of goods, like the baskets in Functions of Several Variables and Level Curves. It can be a list of prices, a list of policy settings, or a point in space. With two entries, you can draw it as an arrow from the origin: the vector (3, 2) goes 3 steps right and 2 up.
Two operations are easy.
- Adding. Add matching entries. If Tuesday's sales are (8, 25, 10), the two-day total is (10 + 8, 20 + 25, 5 + 10) = (18, 45, 15). The vectors must have the same dimension.
- Scaling. Multiply every entry by one number, called a scalar. If Maya doubles Monday's sales, she gets 2 × (10, 20, 5) = (20, 40, 10).
On a graph, adding two arrows means placing the second at the tip of the first. With (3, 2) and (1, 3), the sum is (4, 5).
The dot product: adding up price times quantity
The most useful way to combine two vectors of the same dimension is the dot product. Multiply matching entries, then add the results. It gives one number.
Maya's prices are p = (4, 5, 6) and Monday's sales are q = (10, 20, 5). Then
p · q = 4 × 10 + 5 × 20 + 6 × 5 = 40 + 100 + 30 = 170
That is her revenue. The dot product is how you total "price times quantity" across many goods. A consumer's spending, a firm's cost of inputs and the value of a portfolio are all dot products. In Budget Constraints in Detail the budget line itself is p · x ≤ m, where x is the bundle and m is income.
A smaller case to practice: (1, 2, 3) · (4, 5, 6) = 4 + 10 + 18 = 32.
Matrices: tables of numbers
Now suppose Maya keeps a record of two days. A matrix stacks several vectors into a table. Put each day in a row:
Strawberry Mango Green
Monday 10 20 5
Tuesday 8 25 10 This is a 2 × 3 matrix: 2 rows, 3 columns. Always say rows first. Call it Q. The entry in row 2, column 1 is 8, written Q₂₁, the number of strawberry smoothies on Tuesday.
A matrix is square when it has as many rows as columns. Two special ones are worth knowing now. The identity matrix, written I, is square with 1s down the diagonal and 0s elsewhere; for size 2 it is the table with rows (1, 0) and (0, 1). The zero matrix has only zeros. The transpose of a matrix, written with a small T, flips rows into columns. Transposing Q gives a 3 × 2 matrix with Monday and Tuesday as columns.
You add matrices of the same size entry by entry, and scale them by multiplying every entry, exactly as with vectors. Add Monday-Tuesday for last week to this week and you have a matrix of totals.
Multiplying a matrix by a vector
Here is the payoff. What was revenue for each day? Each row of Q dotted with the price vector p. Monday we know is 170. Tuesday is 4 × 8 + 5 × 25 + 6 × 10 = 32 + 125 + 60 = 217.
Matrix notation does both at once. Writing the product Qp, you get the vector (170, 217). The rule: each entry of the answer is a row of the matrix dotted with the vector. For this to work, the number of columns of Q (3) must equal the dimension of p (3).
A second example, from the kitchen. Strawberry smoothies use 2 bananas and 1 cup of berries. Green ones use 1 banana and 3 cups of berries. Put those recipes in a matrix A with one column per smoothie type and one row per ingredient:
A = [ 2 1 ] (bananas)
[ 1 3 ] (cups of berries) If Maya plans x = (10, 20), meaning 10 strawberry and 20 green, the ingredients needed are Ax:
- Bananas: 2 × 10 + 1 × 20 = 40
- Berries: 1 × 10 + 3 × 20 = 70
So Ax = (40, 70). One short expression replaced two sums. With 500 ingredients and 300 recipes, it still replaces them all.
Multiplying two matrices
To multiply a matrix A by a matrix B, take each row of A and dot it with each column of B. The entry in row i, column j of the answer is row i of A dotted with column j of B.
The sizes must fit: an m × n matrix times an n × k matrix gives an m × k matrix. The inner numbers (n and n) must match, and they vanish. A 2 × 3 times a 3 × 4 is allowed and gives a 2 × 4. A 2 × 3 times a 2 × 3 is not allowed.
Work a small case. Let A have rows (1, 2) and (3, 4), and let B have rows (0, 1) and (1, 0). Then:
AB, row 1: (1, 2) · (0, 1) = 2 (1, 2) · (1, 0) = 1
AB, row 2: (3, 4) · (0, 1) = 4 (3, 4) · (1, 0) = 3
So AB has rows (2, 1) and (4, 3). Now switch the order. BA means rows of B dotted with columns of A:
BA, row 1: (0, 1) · (1, 3) = 3 (0, 1) · (2, 4) = 4
BA, row 2: (1, 0) · (1, 3) = 1 (1, 0) · (2, 4) = 2
So BA has rows (3, 4) and (1, 2). AB and BA are different. This is the biggest surprise for newcomers: matrix multiplication is not commutative. With ordinary numbers, 3 × 5 and 5 × 3 agree. With matrices, order is part of the meaning. (Here B swaps things: AB swaps the columns of A, while BA swaps the rows.) What does hold is the usual regrouping: (AB)C = A(BC), and A(B + C) = AB + AC.
The identity matrix plays the role of the number 1: AI = IA = A for any square A of matching size.
Where economists use matrices
- Input-output tables. Each industry's inputs come from other industries. A matrix records how many cents of steel go into a dollar of cars, and so on. Multiplying it by an output vector tells you total inputs.
- Systems of equations. A market with many goods has one supply-demand equation per good. A matrix gathers the coefficients; see Solving Linear Systems With Matrices.
- Optimization. The second derivatives of a function of several variables form a matrix (the Hessian). Whether you have a maximum depends on its properties, as in Second-Order Conditions, Concavity and Convexity.
- Data. A dataset with 1,000 people and 10 measurements is a 1,000 × 10 matrix, and regression is written entirely in matrix form.
Finance uses the same ideas: a portfolio is a vector of holdings, and prices are another vector. The value is the dot product, the same operation that totaled Maya's day.
A matrix is a machine
Here is another way to see it. Feed a vector into a matrix and out comes another vector. The recipe matrix A takes a production plan and returns a shopping list. A different matrix could take a list of hours worked in each factory and return units made of each product. Chain two machines and you multiply the matrices: if B turns hours into units, and A turns units into ingredients, then AB turns hours straight into ingredients. The sizes fit, because B's output dimension is A's input dimension.
This view explains why the order matters. First sewing and then painting is not the same as first painting and then sewing. Each machine does its own job on whatever arrives, so swapping the sequence usually changes the result.
It also explains the identity matrix. A machine that returns exactly what you put in does nothing, and I is that machine. Later you will ask the reverse question: given the shopping list, which plan produced it? That is the work of an inverse, and it is the heart of Determinants, Inverses and Cramer's Rule.
A common mistake: ignoring sizes and order
The first slip is trying to multiply matrices whose sizes do not match. A 3 × 2 matrix times a 3 × 2 matrix is undefined, because the inner numbers 2 and 3 disagree. Write the sizes next to the matrices before you start, and check the inner pair.
The second is assuming AB = BA. If you want to simplify an expression and swap two matrices "because multiplication is commutative," you have broken a rule. Keep the order.
The third is multiplying entry by entry. Entry-by-entry multiplication is not matrix multiplication. Every entry of a product is a whole row dotted with a whole column.
The fourth is mixing up rows and columns in the notation. Always read sizes as rows × columns, and in a product, the answer takes the row count of the left matrix and the column count of the right one.
Words to know
Vector an ordered list of numbers, such as a bundle of goods or a list of prices.
Scalar a single ordinary number used to scale a vector or matrix.
Dot product the sum of matching entries multiplied together, giving one number.
Matrix a rectangular table of numbers described by its rows and columns.
Identity matrix a square matrix with 1s on the diagonal and 0s elsewhere, which leaves other matrices unchanged when you multiply.
Transpose the matrix you get by turning rows into columns.
Matrix multiplication the operation where each entry is a row of the first matrix dotted with a column of the second.
Check yourself
- What is the dimension of the vector (2, 7, 1, 9), and what is the sum of (2, 7, 1, 9) and (1, 1, 1, 1)?
- Compute the dot product of prices p = (3, 2, 5) and quantities q = (4, 10, 2). What does it mean in a shop?
- A 2 × 3 matrix is multiplied by a 3 × 5 matrix. Is the product defined, and what size is it?
- Using A with rows (2, 1) and (1, 3) and the plan x = (5, 10), find Ax.
- With A with rows (1, 2) and (3, 4) and B with rows (0, 1) and (1, 0), compute AB.
- Explain why AB and BA can differ, and why a 3 × 2 times a 3 × 2 cannot be multiplied.
Show the answers
- Dimension 4; the sum is (3, 8, 2, 10).
- 3 × 4 + 2 × 10 + 5 × 2 = 12 + 20 + 10 = 42, the revenue (or total spending) from selling those quantities at those prices.
- Yes, because the inner sizes are both 3; the product is 2 × 5.
- Bananas 2 × 5 + 1 × 10 = 20 and berries 1 × 5 + 3 × 10 = 35, so Ax = (20, 35).
- Row 1: (1, 2) · (0, 1) = 2 and (1, 2) · (1, 0) = 1; row 2: 4 and 3. So AB has rows (2, 1) and (4, 3).
- Each product pairs rows of the left matrix with columns of the right one, so swapping the order pairs different things (as BA = rows (3, 4) and (1, 2) shows); and a row of 2 entries cannot be dotted with a column of 3 entries.