MATHEMATICS FOR AI • LESSON 2

Matrices

A matrix is a collection of numbers arranged in rows and columns. Matrices allow AI and machine learning systems to organize and work with many numerical values together.

CORE IDEA

A matrix is a group of numbers arranged in rows and columns.

A matrix gives us a structured way to store and work with multiple numerical values at the same time.

01

What Is a Matrix?

A matrix is simply a collection of numbers organized into rows and columns.

For example:

1   2   3
4   5   6

This matrix has 2 rows and 3 columns.

Because it has 2 rows and 3 columns, we call it a 2 × 3 matrix.

02

Rows and Columns

To understand matrices, you need to clearly understand rows and columns.

A row goes from left to right.

A column goes from top to bottom.

1   2   3
4   5   6

→ Row 1:  1   2   3
→ Row 2:  4   5   6

Column 1:  1
           4

Column 2:  2
           5

Column 3:  3
           6

So this matrix contains 2 rows and 3 columns.

03

Matrix Size

The size of a matrix is written as:

rows × columns

For example:

1   2   3
4   5   6

There are 2 rows and 3 columns, so the matrix size is:

2 × 3

Another example:

10   20
30   40
50   60
70   80

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

4 × 2
04

Matrix Elements

Each individual number inside a matrix is called an element.

1   2   3
4   5   6

Here, the elements are:

1
2
3
4
5
6

We can identify an element using its row and column position.

For example, the number 5 is in row 2, column 2.

1   2   3
4   5   6
    ↑
  row 2
  column 2
05

Matrices in the Real World

Matrices are useful whenever we need to organize many numerical values into a structured format.

For example, imagine the marks of three students in three subjects.

Math   Science   English

80       75        90
70       85        88
95       92        96

Each row can represent one student, while each column represents one subject.

This makes it easy to store and process the information mathematically.

06

Matrices in AI

Matrices are extremely important in artificial intelligence and machine learning because AI systems work with large amounts of numerical data.

For example, an image can be represented using numbers.

0   0   255
0   128 255
255 255 0

Each number can represent information about a pixel. A larger image can contain millions of numerical values.

Neural networks also use matrices to store weights and perform mathematical calculations.

07

Scalar, Vector, and Matrix

Now we can connect the three basic numerical structures we have learned.

Scalar

5


Vector

[5, 10, 15]


Matrix

1   2   3
4   5   6

A scalar contains one number.

A vector contains multiple numbers in one organized sequence.

A matrix organizes numbers into rows and columns.

08

Why Matrices Matter in AI

Matrices are one of the most important mathematical structures used in machine learning.

They are used to represent data, model parameters, neural network weights, images, and many other numerical structures.

Data
  ↓
Matrix
  ↓
Mathematical Operations
  ↓
Machine Learning Model
  ↓
Prediction

Understanding matrices is therefore essential before learning matrix operations and matrix multiplication.

WHAT TO REMEMBER

A matrix is a collection of numbers arranged in rows and columns.

The size of a matrix is written as rows × columns. Matrices are used extensively in AI and machine learning to organize data, store model parameters, represent images, and perform mathematical operations.