Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Matrices and vectors are convenient tools for representing linear systems with compact notation that can be processed by a computer.

For example, say you are analyzing the molar flow rates resulting from a flash distillation process.

Flash distillation process

The steady-state mole balances for the total process and component A are

10=L˙+V˙5=0.3L˙+0.8V˙\begin{align} 10 &= \dot L + \dot V \\ 5 &= 0.3 \dot L + 0.8 \dot V \end{align}

These equations can equivalently be represented using matrices and vectors as

[105]=[110.30.8][L˙V˙]\begin{bmatrix} 10 \\ 5 \end{bmatrix} = \begin{bmatrix} 1 & 1 \\ 0.3 & 0.8 \end{bmatrix} \begin{bmatrix} \dot L \\ \dot V \end{bmatrix}

We will learn why these representations are equivalent shortly. Importantly, because our mole balances can be written in this way, they are a system of linear equations that can be solved using techniques of linear algebra.

Definition

A matrix is a rectangular array of quantities, which we call its elements, that are laid out in horizontal rows and vertical columns. We will typically denote a matrix by a bold, capital letter such as A.

A=[0.31500.216]\vv{A} = \begin{bmatrix} 0.3 & 1 & -5 \\ 0 & -0.2 & 16 \end{bmatrix}

An m x n matrix has m rows and n columns. A is a 2 x 3 matrix. We will sometimes refer to elements of a matrix by their row and column

A=[A11A12A13A21A22A23]\vv{A} = \begin{bmatrix} A_{11} & A_{12} & A_{13} \\ A_{21} & A_{22} & A_{23} \end{bmatrix}

For example, A12=1A_{12} = 1 and A23=16A_{23} = 16 for A given above.

A vector is a matrix with either one column (a column vector) or one row (a row vector). We will typically denote a vector by a bold, lowercase letter such as b

b=[12]c=[101]\vv{b} = \begin{bmatrix} 1 \\ 2 \end{bmatrix} \qquad \vv{c} = \begin{bmatrix} -1 & 0 & 1 \end{bmatrix}

b is a 2-element column vector that is also a 2 x 1 matrix, while c is a 3-element row vector that is also a 1 x 3 matrix. When referring to elements of a vector, it typical to only use one index

b=[b1b2]c=[c1c2c3]\vv{b} = \begin{bmatrix} b_1 \\ b_2 \end{bmatrix} \qquad \vv{c} = \begin{bmatrix} c_1 & c_2 & c_3 \end{bmatrix}

For b and c given above, b2=2b_2 = 2 and c2=0c_2 = 0. Note that it becomes ambiguous whether you have a column vector or a row vector if you are refering to elements in this way.

There are some other types of “special” matrices.

There are several other types of special matrices, but we will leave those for a longer course on linear algebra!

Addition and scalar multiplication

For example, given

A=[1205]B=[1001]\vv{A} = \begin{bmatrix} -1 & 2 \\ 0 & 5 \end{bmatrix} \qquad \vv{B} = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}

Compute 2AB2\vv{A} - \vv{B}.


2AB=2[1205][1001]=[24010][1001]=[3409]\begin{align} 2\vv{A}-\vv{B} &= 2 \begin{bmatrix} -1 & 2 \\ 0 & 5 \end{bmatrix} - \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \\ &= \begin{bmatrix} -2 & 4 \\ 0 & 10 \end{bmatrix} - \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix} \\ &= \begin{bmatrix} -3 & 4 \\ 0 & 9 \end{bmatrix} \end{align}

Matrix multiplication

C = AB is defined if A has the same number of columns as B has rows. If A is m x p and B is p x n, C is m x n and its elements are

Cij=k=1pAikBkjC_{ij} = \sum_{k=1}^p A_{ik} B_{kj}

Example:

[354063][2250]=[3×2+5×53×2+5×04×2+0×54×2+0×06×2+3×56×2+3×0]=[316882712]\begin{align} \begin{bmatrix} 3 & 5 \\ 4 & 0 \\ -6 & -3 \end{bmatrix} \begin{bmatrix} 2 & -2 \\ 5 & 0 \end{bmatrix} &= \begin{bmatrix} 3\times2 + 5\times5 & 3\times-2 + 5\times0 \\ 4\times2 + 0\times5 & 4\times-2 + 0\times0 \\ -6\times2 + -3\times5 & -6\times-2 + -3\times0 \end{bmatrix} \\ &= \begin{bmatrix} 31 & -6 \\ 8 & -8 \\ -27 & 12 \end{bmatrix} \end{align}

Multiplying with a vector works the same!

[354063][12]=[3×1+5×24×1+0×26×1+3×2]=[8412]\begin{align} \begin{bmatrix} 3 & 5 \\ 4 & 0 \\ -6 & -3 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \end{bmatrix} &= \begin{bmatrix} 3 \times 1 + 5 \times 2 \\ 4 \times 1 + 0 \times 2 \\ -6 \times 1 + -3 \times 2 \end{bmatrix} \\ &= \begin{bmatrix} 8 \\ 4 \\ -12 \end{bmatrix} \end{align}

Transpose

AT\vv{A}^{\rm T} is the transpose of A, and its elements are obtained by “flipping” the rows and columns:

AijT=AjiA_{ij}^{\rm T} = A_{ji}

Example:

[1243]T=[1423]\begin{bmatrix} 1 & 2 \\ 4 & 3 \end{bmatrix}^{\rm T} = \begin{bmatrix} 1 & 4 \\ 2 & 3 \end{bmatrix}

A matrix is called symmetric if AT=A\vv{A}^{\rm T} = \vv{A}.

Skill builder problems

Given the matrices:

A=[022413]B=[021243]C=[304122654]D=[053524340]\vv{A} = \begin{bmatrix} 0 & 2 \\ 2 & 4 \\ 1 & 3 \\ \end{bmatrix} \quad \vv{B} = \begin{bmatrix} 0 & 2 &1 \\ 2 & 4 & 3 \end{bmatrix} \quad \vv{C} = \begin{bmatrix} 3 & 0 & 4 \\ -1 & 2 & 2 \\ 6 & 5 & -4 \end{bmatrix} \quad \vv{D} = \begin{bmatrix} 0 & -5 & -3 \\ -5 & 2 & 4 \\ -3 & 4 & 0 \end{bmatrix}

and vectors:

a=[13]b=[02]c=[201]\vv{a} = \begin{bmatrix} 1 \\ 3 \end{bmatrix} \quad \vv{b} = \begin{bmatrix} 0 & 2 \end{bmatrix} \quad \vv{c} = \begin{bmatrix} 2 \\ 0 \\ -1 \end{bmatrix}

Compute the following or explain why it is undefined.

Solution to Exercise 1
2A=[202222242123]=[044826]2\vv{A} = \begin{bmatrix} 2 \cdot 0 & 2 \cdot 2 \\ 2 \cdot 2 & 2 \cdot 4 \\ 2 \cdot 1 & 2 \cdot 3 \end{bmatrix} = \begin{bmatrix} 0 & 4 \\ 4 & 8 \\ 2 & 6 \end{bmatrix}
Solution to Exercise 2

Undefined because the shape of A (3×2) is different from the shape of B (2×3).

Solution to Exercise 3
AT+B=[021243]+[021243]=[0+02+21+12+24+43+3]=[042486]\begin{align} \vv{A}^{\rm T} + \vv{B} &= \begin{bmatrix} 0 & 2 & 1 \\ 2 & 4 & 3 \end{bmatrix} + \begin{bmatrix} 0 & 2 & 1\\ 2 & 4 & 3 \end{bmatrix} \\ &= \begin{bmatrix} 0+0 & 2+2 & 1+1 \\ 2+2 & 4+4 & 3+3 \end{bmatrix} \\ &= \begin{bmatrix} 0 & 4 & 2 \\ 4 & 8 & 6 \end{bmatrix} \end{align}

(or, AT=B\vv{A}^{\rm T} = \vv{B} so AT+B=2B\vv{A}^{\rm T} + \vv{B} = 2\vv{B}.)

Solution to Exercise 4
CD=[300(5)4(3)1(5)22246(3)5440]=[357402914]\begin{align} \vv{C} -\vv{D} &= \begin{bmatrix} 3-0 & 0-(-5) & 4-(-3) \\ -1-(-5) & 2-2 & 2-4 \\ 6-(-3) & 5-4 & -4-0 \end{bmatrix} \\ &= \begin{bmatrix} 3 & 5 & 7 \\ 4 & 0 & -2 \\ 9 & 1 & -4 \end{bmatrix} \end{align}
Solution to Exercise 5
Aa=[01+2321+4311+33]=[61410]\begin{align} \vv{Aa} &= \begin{bmatrix} 0 \cdot 1 + 2 \cdot 3 \\ 2 \cdot 1 + 4 \cdot 3 \\ 1 \cdot 1 + 3 \cdot 3 \end{bmatrix} \\ &= \begin{bmatrix} 6 \\ 14 \\ 10 \end{bmatrix} \end{align}
Solution to Exercise 6

Undefined because A has 2 columns but b has 1 row.

Solution to Exercise 7

Undefined because A has 2 columns but c has 3 rows.

Solution to Exercise 8
Bc=[02+20+1122+40+31]=[11]\begin{align} \vv{Bc} &= \begin{bmatrix} 0 \cdot 2 + 2 \cdot 0 + 1 \cdot -1 \\ 2 \cdot 2 + 4 \cdot 0 + 3 \cdot -1 \end{bmatrix} \\ &= \begin{bmatrix} -1 \\ 1 \end{bmatrix} \end{align}
Solution to Exercise 9
cTA=[021][022413]=[20+02+1122+0413]=[11]\begin{align} \vv{c}^{\rm T} \vv{A} &= \begin{bmatrix} 0 & 2 & -1\end{bmatrix} \begin{bmatrix} 0 & 2 \\ 2 & 4 \\ 1 &3 \end{bmatrix} \\ &= \begin{bmatrix} 2 \cdot 0 + 0 \cdot 2 + -1 \cdot 1 & 2 \cdot 2 + 0 \cdot 4 \cdot -1 \cdot 3 \end{bmatrix} \\ &= \begin{bmatrix} -1 & 1 \end{bmatrix} \end{align}