In the previous article, we looked at what linear algebra is and why it matters in computer science and artificial intelligence. We saw that computers often need to work with large amounts of information, and linear algebra gives us a way to represent and manipulate that information.

Now it is time to start with the basic building blocks. Before we get into matrix multiplication, linear equations, eigenvalues, or anything more advanced, we need to understand three simple ideas: Scalars, vectors, and matrices.

You will see these three words again and again throughout this series. Understanding them properly now will make the later topics much easier.

 

What Is a Scalar?

Let’s start with the simplest one. A scalar is simply a single numerical value. For example: 55, 3, 310, 5, 10.5 etc. These are all scalars.

There is nothing complicated about them. A scalar represents one quantity.

For example, if the temperature outside is 25°C, we can represent the temperature as: 25

If the price of a book is ₹500, we can represent it as: 500

If a machine learning model has a learning rate of 0.01, that is also a scalar.

So, whenever you have one numerical value representing one quantity, you can think of it as a scalar.

Why is it called a scalar?

The word scalar is used to distinguish a single quantity from objects that contain multiple values, such as vectors and matrices. You will often see scalars used to modify other mathematical objects.

For example: 2[3,4] = [6,8] 

Here, 2 is a scalar. It changes the size of the vector. We will explore this operation properly in the next article.

 

What Is a Vector?

Now let’s move from one number to several numbers.

Suppose I tell you that a person scored:

  • 80 in Mathematics
  • 75 in Computer Science
  • 90 in Physics

We could write these values separately: 80, 75, 90

But it is often more useful to keep them together: [80,75,90]

This collection of numbers can be represented as a vector. A vector is an ordered collection of numbers.

For example: v = [3,5] is a vector containing two values.

And: v=[2,7,4,9] is a vector containing four values.

The individual values inside a vector are often called components or elements.

So in: v=[3,5]  the vector has two components: 3 and 5

 

Vectors Are More Than Just Lists of Numbers

At this point, you might think: “So a vector is just a list?”

In a computational sense, a vector can certainly be stored like a list of numbers. But mathematically, a vector can represent much more than that.

A vector can represent position, direction, movement, features, measurements, or other quantities, depending on the problem.

For example, consider: [3,2]

In geometry, this can represent a point at coordinates x=3 and y=2. It can also represent a movement of 3 units horizontally and 2 units vertically.

In machine learning, however, the same kind of vector could represent features of a data point.

For example: [1200,3,2,10] could represent some properties of a house:

  • 1200 square feet
  • 3 bedrooms
  • 2 bathrooms
  • 10 years old

The numbers themselves don’t tell us whether something is a “geometric vector” or a “data vector.” The meaning comes from the context in which we use it.

 

How Computers Use Vectors

Vectors are extremely useful in computer science because computers frequently need to represent multiple related values together.

Suppose you are building a system that stores information about a student.

You might have: [85,78,92,88] representing marks in four subjects.

Or you might represent a person’s characteristics as: [21,175,68] where the values could represent age, height, and weight.

In machine learning, a vector can represent the features of one example. If you have 10 features describing something, you can represent those 10 features as a vector with 10 components.

This idea becomes extremely important when we start working with datasets.

 

What Is the Dimension of a Vector?

The number of components in a vector is called its dimension.

  • For example: v=[3,5] has two components, so it is a 2-dimensional vector.
  • Similarly: v=[1,4,7] is a 3-dimensional vector.
  • And: v=[2,5,8,1,6]  is a 5-dimensional vector.

This idea becomes especially important in machine learning. If a dataset has 20 features for every data point, we can represent each data point using a vector with 20 components.

The vector therefore lives in a 20-dimensional space. Don’t worry if that sounds strange. A 20-dimensional space is difficult for us to visualize, but computers have no problem working with it.

 

What Is a Matrix?

Now imagine that instead of having information about one student, we have information about many students.

We could have: [80,75,90] 

for one student, and: [72,88,81] for another.

Instead of keeping these vectors separately, we can organize them into rows and columns:

[80 75 90 72 88 81 91 84 95]\begin{bmatrix} 80 & 75 & 90\\ 72 & 88 & 81\\ 91 & 84 & 95 \end{bmatrix}

This is a matrix.

A matrix is a rectangular arrangement of numbers organized into rows and columns.

The matrix above has:

  • 3 rows
  • 3 columns

So we call it a 3 × 3 matrix.

 

Rows and Columns

Consider this matrix:  A= \begin{bmatrix} 2 & 4 & 6\\ 1 & 3 & 5 \end{bmatrix}

It has two rows: [2,4,6] and: [1,3,5] 

It also has three columns: [21][43][65] \[\begin{bmatrix}2\\1\end{bmatrix}\quad\begin{bmatrix}4\\3\end{bmatrix}\quad\begin{bmatrix}6\\5\end{bmatrix}\]

Therefore, \(A\) is a \(2 \times 3\) matrix. The first number tells us the number of rows, and the second tells us the number of columns.

 

Why Are Matrices Important in Computer Science?

Matrices become incredibly useful when we have a large amount of structured information.

Let’s return to our image example. A grayscale image can be represented as a matrix where each element represents the intensity of a pixel.

For a very small image, we might have: [0 50 100 150 200 255 100 50 0]\begin{bmatrix} 0 & 50 & 100\\ 150 & 200 & 255\\ 100 & 50 & 0 \end{bmatrix}

Each number represents the intensity of a pixel.

A real image might contain millions of pixels, so the matrix would be much larger.

The computer doesn’t need to think of it as a “picture” at this level. It can work with the numerical representation.

This is one reason matrices are so important in computer vision and image processing.

 

Scalars, Vectors, and Matrices Together

Now we can see the relationship between the three.

A scalar is one value: 55

A vector is an ordered collection of values: [2,4,6][2,4,6]

A matrix is an arrangement of values in rows and columns: [2 4 6 8]\begin{bmatrix} 2 & 4\\ 6 & 8 \end{bmatrix}

You can think of them as different ways of organizing numerical information.

Scalar
   ↓
One value

Vector
   ↓
A collection of values

Matrix
   ↓
A collection of values arranged in rows and columns

There is an important connection here.

A vector can be viewed as a special case of a matrix, for example, a matrix with one column. But for now, it is useful to keep the concepts separate because they are commonly used and discussed differently.

 

A Simple AI Example

Let’s bring these ideas back to artificial intelligence.

Suppose we are building a machine learning model to predict whether a house is expensive.

We might describe each house using four features:

\(\text{[area, bedrooms, bathrooms, age]}\)

For one house, this might become:

[1500,3,2,5][1500,3,2,5]

That is a vector.

Now suppose we have 1,000 houses.

We could represent the entire dataset as a matrix:

 X= \begin{bmatrix} 1500 & 3 & 2 & 5\\ 1200 & 2 & 1 & 10\\ 2000 & 4 & 3 & 2\\ \vdots & \vdots & \vdots & \vdots \end{bmatrix}

Now we have:

  • One house → one vector
  • Many houses → a matrix
  • Individual values → scalars

This simple pattern appears repeatedly in machine learning.

 

A Simple Neural Network Example

The same idea appears inside neural networks.

Suppose a neural network receives several input values.

Those inputs can be represented as a vector.

The model has weights, which can be organized into matrices.

Individual values such as a bias or learning rate can be scalars.

So even though a neural network can contain millions or billions of parameters, many of those values can be organized and processed using the mathematical structures we are learning here.

This is one of the reasons these concepts are worth understanding before diving deeper into machine learning.

 

Why Not Just Use Python Lists?

If you are a programmer, you might be thinking:

“Can’t I just use a Python list?”

You can.

For example:

x = [3, 5, 7]

is a perfectly valid way to store a collection of numbers.

But mathematical vectors and matrices have additional structure and operations associated with them.

In Python, libraries such as NumPy provide specialized structures for numerical computing.

For example:

import numpy as np
x = np.array([3, 5, 7])
A = np.array([
    [1, 2],
    [3, 4]
])

Now we can perform mathematical operations on these objects efficiently.

We will use programming examples more as the series progresses, but it is important to first understand what the mathematical objects actually represent.

At this point, we haven’t done anything particularly complicated. We have simply learned that numbers can be organized in different ways depending on what we are trying to represent.

  • A scalar gives us a single value.
  • A vector lets us work with a collection of related values.
  • A matrix lets us organize values into rows and columns.

These ideas may look simple, but they are the foundation for much more advanced topics. When we eventually talk about matrix multiplication, linear equations, vector spaces, eigenvalues, neural networks, and PCA, these same objects will keep appearing.

The important thing is not to memorize the definitions and move on.

Try to understand what each object is representing.

If you see: 55 think one quantity.

If you see: [2,4,6] think a collection of related values.

If you see: [2 4 6 8]\begin{bmatrix} 2 & 4\\ 6 & 8 \end{bmatrix} think values organized in rows and columns.

Once that way of thinking becomes natural, the rest of linear algebra becomes much easier to approach.

 

What We’ll Learn Next

We now know what scalars, vectors, and matrices are. But simply representing numbers isn’t enough. We also need to know how to work with them.

  • Can we add two vectors?
  • What happens when we multiply a vector by a number?
  • How do we multiply two matrices?
  • What exactly is a dot product?
  • And why are these operations so important in AI?

In the next article, we’ll answer these questions and learn about: Vector and Matrix Operations: Dot Product, Multiplication, and Transpose.