evan's notes
cal 3discreteodeenv systems

On this page

  • 1. The Big Idea
  • 2. Matrix Anatomy
  • Entries
  • Square Matrices
  • Main Diagonal and Trace
  • 3. Entrywise Operations
  • Addition and Subtraction
  • Scalar Multiplication
  • 4. Matrix Multiplication
  • Size Rule
  • How to Multiply
  • Order Matters
  • 5. The Identity Matrix
  • 6. Transpose
  • Transpose Rules
  • 7. Inverse Matrices
  • Why Inverses Matter
  • 8. Inverse of a 2×22\times 22×2 Matrix
  • 9. Algebraic Properties of Inverses
  • 10. Elementary Matrices
  • Row Operations as Multiplication
  • Small Example
  • 11. Row Equivalence
  • 12. Finding an Inverse by Row Reduction
  • When the Method Fails
  • 13. Equivalent Conditions for Invertibility
  • 14. Problem-Solving Routine
  • 15. Key Takeaways
  • Mini-Self-Check

Linear Algebra

§2 Matrices and Matrix Operations

Evan Luo · Feb 24, 2026

Linear Algebra

§2 Matrices and Matrix Operations

Evan LuoFeb 24, 2026

12 min read

1. The Big Idea

A matrix is a rectangular array of numbers.

That sounds simple, but matrices are powerful because they let us organize many numbers at once. In linear algebra, matrices can represent systems of equations, transformations, data tables, or rules for combining vectors.

Example:

A=[123456]A= \begin{bmatrix} 1&2&3\\ 4&5&6 \end{bmatrix} A=[14​25​36​]

This matrix has 2 rows and 3 columns, so its size is

2×32\times 3 2×3

Always read matrix size as

rows×columns\text{rows}\times\text{columns} rows×columns

Rows go across. Columns go down.


2. Matrix Anatomy

Before doing operations with matrices, it helps to know the vocabulary.

WordMeaning
rowa horizontal line of entries
columna vertical line of entries
entryone number inside the matrix
sizenumber of rows by number of columns
square matrixsame number of rows and columns
main diagonalentries from top-left to bottom-right
tracesum of the main diagonal entries

Entries

The entry in row iii, column jjj is written as

aija_{ij} aij​

For example, in

A=[123456]A= \begin{bmatrix} 1&2&3\\ 4&5&6 \end{bmatrix} A=[14​25​36​]

we have

a21=4a_{21}=4 a21​=4

because row 2, column 1 contains 4.

The order of the subscripts matters: a21a_{21}a21​ means row 2, column 1, not row 1, column 2.

Square Matrices

A square matrix has the same number of rows and columns.

Example of a 2×22\times 22×2 square matrix:

[1234]\begin{bmatrix} 1&2\\ 3&4 \end{bmatrix} [13​24​]

Example of a 3×33\times 33×3 square matrix:

[123456789]\begin{bmatrix} 1&2&3\\ 4&5&6\\ 7&8&9 \end{bmatrix} ​147​258​369​​

Square matrices are special because ideas like determinants, inverses, and trace only make sense for square matrices.

Main Diagonal and Trace

In a square matrix, the main diagonal goes from top left to bottom right.

For

A=[123456789]A= \begin{bmatrix} 1&2&3\\ 4&5&6\\ 7&8&9 \end{bmatrix} A=​147​258​369​​

the main diagonal entries are

1, 5, 91,\ 5,\ 9 1, 5, 9

The trace is the sum of those entries:

tr⁡(A)=1+5+9=15\operatorname{tr}(A)=1+5+9=15 tr(A)=1+5+9=15

For an n×nn\times nn×n matrix,

tr⁡(A)=a11+a22+⋯+ann\operatorname{tr}(A)=a_{11}+a_{22}+\cdots+a_{nn} tr(A)=a11​+a22​+⋯+ann​

Trace is only defined for square matrices because non-square matrices do not have a complete main diagonal from corner to corner.


3. Entrywise Operations

Some matrix operations happen entry by entry. Nothing fancy happens with rows and columns yet: matching positions are combined with matching positions.

Addition and Subtraction

Matrices can be added or subtracted only if they have the same size.

If

A=[1234],B=[5678]A= \begin{bmatrix} 1&2\\ 3&4 \end{bmatrix}, \qquad B= \begin{bmatrix} 5&6\\ 7&8 \end{bmatrix} A=[13​24​],B=[57​68​]

then

A+B=[1+52+63+74+8]=[681012]A+B= \begin{bmatrix} 1+5&2+6\\ 3+7&4+8 \end{bmatrix} = \begin{bmatrix} 6&8\\ 10&12 \end{bmatrix} A+B=[1+53+7​2+64+8​]=[610​812​]

You can subtract the same way:

A−B=[1−52−63−74−8]=[−4−4−4−4]A-B= \begin{bmatrix} 1-5&2-6\\ 3-7&4-8 \end{bmatrix} = \begin{bmatrix} -4&-4\\ -4&-4 \end{bmatrix} A−B=[1−53−7​2−64−8​]=[−4−4​−4−4​]

If the sizes do not match, addition and subtraction are not defined.

Scalar Multiplication

A scalar is just a number.

To multiply a matrix by a scalar, multiply every entry by that scalar:

3[1234]=[36912]3 \begin{bmatrix} 1&2\\ 3&4 \end{bmatrix} = \begin{bmatrix} 3&6\\ 9&12 \end{bmatrix} 3[13​24​]=[39​612​]

Scalar multiplication stretches every entry by the same factor.


4. Matrix Multiplication

Matrix multiplication is the first operation that is not entry-by-entry.

Instead, it combines rows of the first matrix with columns of the second matrix.

Size Rule

If AAA is m×nm\times nm×n and BBB is n×pn\times pn×p, then ABABAB is defined and has size m×pm\times pm×p.

The inside dimensions must match:

(m×n)(n×p)(m\times n)(n\times p) (m×n)(n×p)

The outside dimensions give the size of the answer:

m×pm\times p m×p

So the quick rule is:

(m×n)(n×p)=m×p(m\times n)(n\times p)=m\times p (m×n)(n×p)=m×p

Example:

ProductDefined?Result size
(2×3)(3×4)(2\times 3)(3\times 4)(2×3)(3×4)yes2×42\times 42×4
(3×2)(3×4)(3\times 2)(3\times 4)(3×2)(3×4)noinside dimensions do not match
(5×1)(1×6)(5\times 1)(1\times 6)(5×1)(1×6)yes5×65\times 65×6

How to Multiply

To get entry cijc_{ij}cij​ of ABABAB:

  1. Take row iii of AAA.
  2. Take column jjj of BBB.
  3. Multiply matching entries.
  4. Add the results.

This is a dot product between a row and a column.

Example:

A=[1234],B=[5678]A= \begin{bmatrix} 1&2\\ 3&4 \end{bmatrix}, \qquad B= \begin{bmatrix} 5&6\\ 7&8 \end{bmatrix} A=[13​24​],B=[57​68​]

Then

AB=[1(5)+2(7)1(6)+2(8)3(5)+4(7)3(6)+4(8)]AB= \begin{bmatrix} 1(5)+2(7)&1(6)+2(8)\\ 3(5)+4(7)&3(6)+4(8) \end{bmatrix} AB=[1(5)+2(7)3(5)+4(7)​1(6)+2(8)3(6)+4(8)​]

So

AB=[19224350]AB= \begin{bmatrix} 19&22\\ 43&50 \end{bmatrix} AB=[1943​2250​]

Order Matters

Usually,

AB≠BAAB\neq BA AB=BA

Matrix multiplication is not commutative.

This is not just a technical detail. Matrix multiplication often represents doing one action after another. If you change the order, you change the process.

For ordinary numbers, 2⋅3=3⋅22\cdot 3=3\cdot 22⋅3=3⋅2. For matrices, that kind of swapping usually fails.


5. The Identity Matrix

The identity matrix is the matrix version of the number 111.

For 2×22\times 22×2:

I2=[1001]I_2= \begin{bmatrix} 1&0\\ 0&1 \end{bmatrix} I2​=[10​01​]

For 3×33\times 33×3:

I3=[100010001]I_3= \begin{bmatrix} 1&0&0\\ 0&1&0\\ 0&0&1 \end{bmatrix} I3​=​100​010​001​​

The identity matrix satisfies

AI=AAI=A AI=A

and

IA=AIA=A IA=A

when the multiplication is defined.

The phrase "when the multiplication is defined" matters. The identity matrix has to have the correct size. For example, if AAA is 2×32\times 32×3, then AI3=AAI_3=AAI3​=A and I2A=AI_2A=AI2​A=A.


6. Transpose

The transpose of AAA, written ATA^TAT, is found by switching rows and columns.

If

A=[123456]A= \begin{bmatrix} 1&2&3\\ 4&5&6 \end{bmatrix} A=[14​25​36​]

then

AT=[142536]A^T= \begin{bmatrix} 1&4\\ 2&5\\ 3&6 \end{bmatrix} AT=​123​456​​

The first row of AAA becomes the first column of ATA^TAT.

Transpose Rules

(A+B)T=AT+BT(A+B)^T=A^T+B^T (A+B)T=AT+BT (A−B)T=AT−BT(A-B)^T=A^T-B^T (A−B)T=AT−BT (AT)T=A(A^T)^T=A (AT)T=A (cA)T=cAT(cA)^T=cA^T (cA)T=cAT

The important product rule is

(AB)T=BTAT(AB)^T=B^TA^T (AB)T=BTAT

Notice that the order reverses. Transpose flips how rows and columns interact, so a product has to be reversed when transposed.


7. Inverse Matrices

An inverse is something that undoes another thing.

For ordinary numbers, multiplying by a−1a^{-1}a−1 undoes multiplying by aaa. For matrices, multiplying by A−1A^{-1}A−1 undoes multiplying by AAA.

A square matrix AAA is invertible if there exists a matrix BBB such that

AB=BA=IAB=BA=I AB=BA=I

Then BBB is called the inverse of AAA, written

A−1A^{-1} A−1

So an invertible matrix satisfies

AA−1=A−1A=IAA^{-1}=A^{-1}A=I AA−1=A−1A=I

Only square matrices can be invertible, but not every square matrix is invertible.

Why Inverses Matter

For ordinary equations, to solve

ax=bax=b ax=b

we divide by aaa:

x=a−1bx=a^{-1}b x=a−1b

For matrices, division is replaced by multiplying by an inverse.

If

AX=BAX=B AX=B

then multiply on the left by A−1A^{-1}A−1:

X=A−1BX=A^{-1}B X=A−1B

But if

XA=BXA=B XA=B

then multiply on the right by A−1A^{-1}A−1:

X=BA−1X=BA^{-1} X=BA−1

The side matters because matrix multiplication is not commutative.


8. Inverse of a 2×22\times 22×2 Matrix

For a 2×22\times 22×2 matrix,

A=[abcd]A= \begin{bmatrix} a&b\\ c&d \end{bmatrix} A=[ac​bd​]

the inverse is

A−1=1ad−bc[d−b−ca]A^{-1} = \frac{1}{ad-bc} \begin{bmatrix} d&-b\\ -c&a \end{bmatrix} A−1=ad−bc1​[d−c​−ba​]

provided

ad−bc≠0ad-bc\neq 0 ad−bc=0

The number

ad−bcad-bc ad−bc

is the determinant of AAA.

If

ad−bc=0ad-bc=0 ad−bc=0

then AAA is not invertible.

You will study determinants more deeply in the next section. For now, remember this practical test: for a 2×22\times 22×2 matrix, the inverse formula only works if ad−bcad-bcad−bc is not zero.


9. Algebraic Properties of Inverses

If AAA and BBB are invertible matrices of compatible sizes, then:

RuleMeaning
(A−1)−1=A(A^{-1})^{-1}=A(A−1)−1=Aundoing the inverse gets back to AAA
(AB)−1=B−1A−1(AB)^{-1}=B^{-1}A^{-1}(AB)−1=B−1A−1undo a product in reverse order
(cA)−1=1cA−1(cA)^{-1}=\frac{1}{c}A^{-1}(cA)−1=c1​A−1scalar factors invert too, if c≠0c\neq 0c=0
(AT)−1=(A−1)T(A^T)^{-1}=(A^{-1})^T(AT)−1=(A−1)Ttranspose and inverse work nicely together

The product rule is the one to remember carefully:

(AB)−1=B−1A−1(AB)^{-1}=B^{-1}A^{-1} (AB)−1=B−1A−1

The order reverses for the same reason you undo steps backward. If you put on socks and then shoes, you remove shoes first and socks second.


10. Elementary Matrices

An elementary matrix is created by performing one elementary row operation on an identity matrix.

Start with

I3=[100010001]I_3= \begin{bmatrix} 1&0&0\\ 0&1&0\\ 0&0&1 \end{bmatrix} I3​=​100​010​001​​

If you swap two rows, multiply a row by a nonzero constant, or add a multiple of one row to another, the result is an elementary matrix.

Elementary matrices matter because row operations can be represented as matrix multiplication.

Row operationWhat the elementary matrix does
swap rowsswaps rows of another matrix
scale a rowscales a row of another matrix
add a multiple of one row to anotherperforms elimination

Row Operations as Multiplication

Suppose a row operation is represented by an elementary matrix EEE. Then applying that row operation to AAA is the same as multiplying:

EAEA EA

So if a sequence of elementary matrices reduces AAA to the identity matrix, we can write something like

Ek⋯E2E1A=IE_k\cdots E_2E_1A=I Ek​⋯E2​E1​A=I

That means

A−1=Ek⋯E2E1A^{-1}=E_k\cdots E_2E_1 A−1=Ek​⋯E2​E1​

The original matrix AAA is built by undoing those row operations in the opposite direction:

A=E1−1E2−1⋯Ek−1A=E_1^{-1}E_2^{-1}\cdots E_k^{-1} A=E1−1​E2−1​⋯Ek−1​

For example, if three elementary matrices reduce AAA to III,

E3E2E1A=IE_3E_2E_1A=I E3​E2​E1​A=I

then

A−1=E3E2E1A^{-1}=E_3E_2E_1 A−1=E3​E2​E1​

and

A=E1−1E2−1E3−1A=E_1^{-1}E_2^{-1}E_3^{-1} A=E1−1​E2−1​E3−1​

This is the theoretical reason row-reduction can find inverses.

Small Example

Let

A=[1237]A= \begin{bmatrix} 1&2\\ 3&7 \end{bmatrix} A=[13​27​]

Eliminate the 333 below the first pivot:

R2→R2−3R1R_2\to R_2-3R_1 R2​→R2​−3R1​

This row operation is represented by

E1=[10−31]E_1= \begin{bmatrix} 1&0\\ -3&1 \end{bmatrix} E1​=[1−3​01​]

Then eliminate the 222 above the second pivot:

R1→R1−2R2R_1\to R_1-2R_2 R1​→R1​−2R2​

This is represented by

E2=[1−201]E_2= \begin{bmatrix} 1&-2\\ 0&1 \end{bmatrix} E2​=[10​−21​]

Since applying E1E_1E1​ and then E2E_2E2​ reduces AAA to III, we have

E2E1A=IE_2E_1A=I E2​E1​A=I

Therefore

A−1=E2E1A^{-1}=E_2E_1 A−1=E2​E1​

and the original matrix can be recovered by undoing those elementary matrices in reverse:

A=E1−1E2−1A=E_1^{-1}E_2^{-1} A=E1−1​E2−1​

The main takeaway is not that you should always write inverses this way. The takeaway is that row operations and matrix multiplication are deeply connected.


11. Row Equivalence

Two matrices AAA and BBB are row equivalent if one can be changed into the other using elementary row operations.

This means they have the same row-reduction structure.

For augmented matrices, row equivalence is especially important because row operations preserve the solution set of a system. So row-equivalent augmented matrices represent systems with the same solutions.


12. Finding an Inverse by Row Reduction

To find A−1A^{-1}A−1, place AAA beside the identity matrix:

[A∣I][A\mid I] [A∣I]

Then row-reduce until the left side becomes III.

If the row-reduction succeeds,

[A∣I]→[I∣A−1][A\mid I]\to[I\mid A^{-1}] [A∣I]→[I∣A−1]

The right side is the inverse.

For a 2×22\times 22×2 matrix, the setup looks like

[ab10cd01]\left[ \begin{array}{cc|cc} a&b&1&0\\ c&d&0&1 \end{array} \right] [ac​bd​10​01​]

Row-reduce the left side to the identity matrix. Whatever appears on the right side is A−1A^{-1}A−1.

When the Method Fails

If the left side cannot become III, then AAA is not invertible.

So this method is both a way to find inverses and a way to test whether an inverse exists.


13. Equivalent Conditions for Invertibility

For a square matrix AAA, the following statements all mean the same thing:

A is invertibleA \text{ is invertible} A is invertible A row-reduces to IA \text{ row-reduces to } I A row-reduces to I Ax⃗=0⃗ has only the trivial solutionA\vec{x}=\vec{0} \text{ has only the trivial solution} Ax=0 has only the trivial solution A can be written as a product of elementary matricesA \text{ can be written as a product of elementary matrices} A can be written as a product of elementary matrices det⁡(A)≠0\det(A)\neq 0 det(A)=0

These are different languages for the same idea: AAA does not collapse information, so it can be undone.


14. Problem-Solving Routine

When working with matrices, check the structure before doing calculations.

  1. Check sizes first. Many mistakes happen before any arithmetic begins.
  2. For addition or subtraction, sizes must match. Add or subtract corresponding entries.
  3. For scalar multiplication, multiply every entry. No size restriction beyond having a matrix.
  4. For matrix multiplication, check inside dimensions. If they match, the outside dimensions give the answer size.
  5. For inverses, check that the matrix is square. Non-square matrices do not have ordinary inverses.
  6. When solving with inverses, multiply on the correct side. AX=BAX=BAX=B and XA=BXA=BXA=B are different situations.
  7. To find an inverse, row-reduce [A∣I][A\mid I][A∣I]. If the left side becomes III, the right side is A−1A^{-1}A−1.

15. Key Takeaways

  • Matrix size is always rows by columns.
  • Addition, subtraction, and scalar multiplication happen entry-by-entry.
  • Matrix multiplication uses row-dot-column products.
  • For ABABAB, the inside dimensions must match.
  • Matrix multiplication usually depends on order: AB≠BAAB\neq BAAB=BA.
  • The identity matrix acts like 111 for matrix multiplication.
  • The inverse matrix undoes multiplication by a matrix.
  • Inverse and transpose product rules reverse the order.
  • Row-reduction can find inverses using [A∣I]→[I∣A−1][A\mid I]\to[I\mid A^{-1}][A∣I]→[I∣A−1].

Mini-Self-Check

  1. If AAA is 2×32\times 32×3 and BBB is 3×43\times 43×4, what size is ABABAB?

The inside dimensions match: (2×3)(3×4)(2\times 3)(3\times 4)(2×3)(3×4). The answer has the outside dimensions, so ABABAB is 2×42\times 42×4.

Click to reveal
  1. Can a 2×32\times 32×3 matrix have an ordinary inverse?

No. Ordinary inverses are only defined for square matrices.

Click to reveal
  1. Why is (AB)−1=B−1A−1(AB)^{-1}=B^{-1}A^{-1}(AB)−1=B−1A−1 instead of A−1B−1A^{-1}B^{-1}A−1B−1?

Because undoing a sequence happens in reverse order. If ABABAB means one combined product, the inverse must undo the BBB part first, then the AAA part.

Click to reveal
  1. What does [A∣I]→[I∣A−1][A\mid I]\to[I\mid A^{-1}][A∣I]→[I∣A−1] mean?

It means that if row-reduction turns the left side AAA into the identity matrix, then the right side has become the inverse of AAA.

Click to reveal

Source: https://notes.ohevan.com/notes/linear/02-matrices-and-matrix-operations

© 2026 Evan Luo. All rights reserved.

Back to Linear Algebra

0 reads

·Last edited May 23, 2026
  • newsletter

  • about me

  • sponsor

© 2026 Evan Luo. All rights reserved.