If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

## Multivariable calculus

### Course: Multivariable calculus>Unit 1

Lesson 2: Vectors and matrices

# Matrices, intro

Learn about matrix notation, dimension, addition, and scalar multiplication. Optionally, learn the formula for matrix multiplication.
In addition to vectors, matrices are a fundamental way we can talk about higher-dimensional space. They will show up all over multivariable calculus, so let's get into it.

## What is a matrix?

A matrix is an array of numbers that we surround with square brackets. The dimension of a matrix is how many rows and columns it has, which we write as start text, r, o, w, s, end text, times, start text, c, o, l, u, m, n, s, end text. For example, here is a 2, times, 3 matrix (pronounced "two by three"). The convention is to use uppercase letters for a variable that is a matrix.
$A = \left[ \begin{array}{ccc} \blueD{3} & \maroonD{-2} & \greenD{5} \\ \blueD{4} & \maroonD{2} & \greenD{1} \end{array} \right]$
When a matrix has the same number of rows as columns, we call it a square matrix. For example, the matrix A is non-square. We call the numbers in a matrix its elements, or its entries. To refer to an entry in a matrix, we specify its row then its column in a subscript. The convention is to use lowercase letters for matrix elements.
a, start subscript, 2, comma, 1, end subscript, equals, start color #11accd, 4, end color #11accd, comma, a, start subscript, 1, comma, 3, end subscript, equals, start color #1fab54, 5, end color #1fab54
The transpose of a matrix is that matrix with its rows and columns switched. That is, the entry a, start subscript, i, comma, j, end subscript becomes a, start subscript, j, comma, i, end subscript. We write A, start superscript, T, end superscript to refer to the transpose of A. The transpose also reverses the dimensions of a matrix, so for example A, start superscript, T, end superscript is 3, times, 2.
$A^T = \left[ \begin{array}{cc} \blueD{3} & \blueD{4} \\ \maroonD{-2} & \maroonD{2} \\ \greenD{5} & \greenD{1} \end{array} \right]$
In general, the entries in a matrix don't have to be numbers. For example, some of the matrices we'll encounter in multivariable calculus have functions or even derivative operators as entries.
To learn more about what a matrix is, check out this video. For more on the transpose, check out this video. To get practice with matrix dimensions, try this exercise. To get practice with matrix elements, try this exercise.

## Vectors as matrices

Because a vector is just a list of numbers, we can represent it as a matrix. This is why we can write vectors with matrix notation. We can always write a given vector as a row vector (1, times, n) or as a column vector (n, times, 1). The only difference between row and column vectors is how they work in matrix multiplication.
$\vec{v} = \left[ \begin{array}{ccc} \blueD{1} & \blueD{2} & \blueD{3} \end{array} \right]^T = \left[ \begin{array}{c} \blueD{1} \\ \blueD{2} \\ \blueD{3} \end{array} \right]$
We use the transpose here because otherwise the row vector and column vector are not technically equal, because they have different dimensions.
To learn more about the transpose of vectors, check out this video.

We can add two matrices if they have equal dimensions. The way we add them is to add corresponding components. In symbols, this says that A, plus, B, equals, C means a, start subscript, i, comma, j, end subscript, plus, b, start subscript, i, comma, j, end subscript, equals, c, start subscript, i, comma, j, end subscript.
\begin{aligned} \left[ \begin{array}{cc} \blueD{-1} & \maroonD{3} \\ \blueD{2} & \maroonD{5} \end{array} \right] + \left[ \begin{array}{cc} \blueD{3} & \maroonD{0} \\ \blueD{-4} & \maroonD{-2} \end{array} \right] &= \left[ \begin{array}{cc} \blueD{-1 + 3} & \maroonD{3 + 0} \\ \blueD{2 - 4} & \maroonD{5 - 2} \end{array} \right] \\\\ &= \left[ \begin{array}{cc} \blueD{2} & \maroonD{3} \\ \blueD{-2} & \maroonD{3} \end{array} \right] \end{aligned}
To get practice with matrix addition, check out this exercise.

## Scalar multiplication

We can multiply any matrix by a scalar, which is a fancy word for a number. When we do scalar multiplication, we multiply the scalar into every entry of the matrix. In symbols, this says that x, A, equals, B means x, a, start subscript, i, comma, j, end subscript, equals, b, start subscript, i, comma, j, end subscript.
\begin{aligned} 2 \left[ \begin{array}{cc} \blueD{2} & \maroonD{1} \\ \blueD{4} & \maroonD{3} \end{array} \right] &= \left[ \begin{array}{cc} 2 \cdot \blueD{2} & 2 \cdot \maroonD{1} \\ 2 \cdot \blueD{4} & 2 \cdot \maroonD{3} \end{array} \right] \\ \\ &= \left[ \begin{array}{cc} \blueD{4} & \maroonD{2} \\ \blueD{8} & \maroonD{6} \end{array} \right] \end{aligned}
To get practice with scalar multiplication, check out this exercise.

## Matrix multiplication (optional)

This section is optional because matrix multiplication is most useful when we need to talk about n-dimensional space, while in this course we focus on 2D and 3D. Nonetheless, learning this now provides a great foundation for extending into higher dimensions later.
Unlike with addition and scalar multiplication, we do not just multiply the corresponding entries of two matrices A and B to find their product. Instead, we calculate the dot product of a row vector of A with a column vector of B to find each entry. For example, to find c, start subscript, 1, comma, 2, end subscript of C, equals, A, B, we take the dot product of row 1 of A with column 2 of B:
$\left[ \begin{array}{cc} \bold{\goldD{3}} & \bold{\goldD{1}} \\ -1 & 2 \end{array} \right] \left[ \begin{array}{cc} 4 & \bold{\tealD{4}} \\ 2 & \bold{\tealD{0}} \end{array} \right] = \left[ \begin{array}{cc} ? & \goldD{3} \cdot \tealD{4} + \goldD{1} \cdot \tealD{0} \\ ? & ? \end{array} \right]$
In general, to find entry c, start subscript, i, comma, j, end subscript of C, equals, A, B, we take the dot product of the ith row of A with the jth column of B. Here's the rest of the matrix multiplication above:
\begin{aligned} &\phantom{=}\left[ \begin{array}{cc} \blueD{3} & \maroonD{1} \\ \blueD{-1} & \maroonD{2} \end{array} \right] \left[ \begin{array}{cc} \blueD{4} & \maroonD{4} \\ \blueD{2} & \maroonD{0} \end{array} \right] \\\\ &= \left[ \begin{array}{cc} \blueD{3} \cdot \blueD{4} + \maroonD{1} \cdot \blueD{2} & \blueD{3} \cdot \maroonD{4} + \maroonD{1} \cdot \maroonD{0} \\ \blueD{(-1)} \cdot \blueD{4} + \maroonD{2} \cdot \blueD{2} & \blueD{-1} \cdot \maroonD{4} + \maroonD{2} \cdot \maroonD{0} \end{array} \right] \\ \\ &= \left[ \begin{array}{cc} 14 & 12 \\ 0 & -4 \end{array} \right] \end{aligned}
As a consequence of this definition, we can only multiply two matrices A and B if A has the same number of columns as B has rows. Otherwise we would have to take the dot product of two vectors with different lengths.
We can always multiply two square matrices of the same dimension, such as a 3, times, 3 with a 3, times, 3. Other valid combinations include, for example, a 2, times, 5 with a 5, times, 2, or a 3, times, 1 with a 1, times, 3.
The dimension of the product matrix will be the rows of A and the columns of B. Therefore, the product of a 1, times, 4 matrix with a 4, times, 1 matrix will be a 1, times, 1 matrix, which is interchangeable with a number. On a sidenote, this leads to another way we can write the dot product:
\begin{aligned} \left[ \begin{array}{ccc} 1 & 2 & 3 \end{array} \right] \left[ \begin{array}{c} 4 \\ 5 \\ 6 \end{array} \right] &= (1, 2, 3) \cdot (4, 5, 6) \\ \\ &= 1 \cdot 4 + 2 \cdot 5 + 3 \cdot 6 \\ \\ &= 32 \end{aligned}
To learn more about matrix multiplication, check out this video. For practice, try this exercise.

## What's next

Now that we know matrix fundamentals, it's a good time to step back and think about what matrices mean. Otherwise the formulas and concepts surrounding them can feel unmotivated. The next article presents a way to visualize matrices that will give intuition into how they work. Specifically, it sheds light on how to think about the formula for matrix multiplication, and it prepares us for the final article about determinants.

## Want to join the conversation?

• The Addition example is erroneous, showing 5-2 = -3