Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

Introduction to Vectors

What are Vectors?

Vectors can be thought of as ordered lists or tuples. They are used to store values from a data set.

A vector can be represented as follows:

● 𝑣

● 𝑣

● 𝑣

Now, you will learn about vectors with the help of an example. The following tables contain information
about the height and weight of five people.

Person Height (cm) Weight (kg)

1 155 85

2 170 85

3 150 80

4 165 80

5 155 70

We can represent the height of all five people using the vector ℎ = (155 170 150 165 155). We

can also represent the height and weight of the first person using the vector 𝑣 1 = (155 85 ).

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Similarly, we can create vectors for all five people.

1-D Coordinate Space: ℝ1

The one-dimensional coordinate system is defined using a single line called the number line. Each point
on this line represents a real number and vice versa. All points on this line are measured with respect to
the origin.

Consider the following situation. A rod is being heated, and its temperature is being recorded after every
hour. The following table shows the temperatures after the first, second and third hour.

Time Temperature
(hours) (°C)

1 -40

2 35

3 30

Here, the temperature of the rod is a data point. Every data point (real number) corresponds to a unique
point on the number line and vice versa.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
2-D Coordinate Space: ℝ2

Some important points related to the 2-D coordinate space are as follows:

● The 2-D coordinate space is defined using two perpendicular lines called the 𝑥-axis and the 𝑦-axis.
● The point of intersection of the axes is called the origin, and all the positions are measured relative
to the origin.
● Any point in the two-dimensional space is represented using an ordered pair of the form (𝑎, 𝑏),
where 𝑎 is the 𝑥 coordinate and 𝑏 is the 𝑦 coordinate.

Consider the following table that shows the ratings given by five users to two movies.

Jurassic Park Three Idiots


User
(Adventure) (Comedy)

Anmol 7 2

Babita 2 6

Chester 5 3

Disha 9 8

Euclid 1 9

Consider the rating given by Anmol. His ratings can be represented by the ordered pair (7, 2), where the
first and the second coordinates refer to the ratings given to Jurassic Park and Three Idiots, respectively.
We can represent the ratings given by all the five users in a similar manner and plot them on the two-
dimensional plane as shown below.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
3-D Coordinate Space: ℝ3

Some important points related to the 3-D coordinate space are as follows:

● The three-dimensional coordinate space is defined using three perpendicular lines called the 𝑥-
axis, the 𝑦-axis and the 𝑧-axis.
● Any point in the three-dimensional space is represented using an ordered triplet of the form
(𝑎, 𝑏, 𝑐) where 𝑎 is the 𝑥 coordinate, 𝑏 is the 𝑦 coordinate and 𝑐 is the 𝑧 coordinate.
● The point of intersection of the axes is called the origin, and all the positions are measured relative
to the origin.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Consider the following table. The table shows the ratings given by five users to three movies.

The Sound of
Jurassic Park Three Idiots
User Music
(Adventure) (Comedy)
(Romance)

Anmol 7 2 6

Babita 2 6 5

Chester 5 3 9

Disha 9 8 6

Euclid 1 9 5

Consider the rating given by Babita. Her ratings can be represented by the ordered triplet (2, 6, 5), where
the first, second and third coordinates refer to the ratings given to Jurassic Park, Three Idiots and The
Sound of Music, respectively. We can represent the ratings given by all the five users in a similar manner
and plot them on the three-dimensional plane. The rating given by Babita is as shown below.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
𝑛-Dimensional Coordinate Space: ℝ𝑛

Each point in the 𝑛-dimensional space is represented by a tuple containing 𝑛 coordinates.

Consider the following table that shows the ratings given by five users to five movies.

Three The Sound of


Jurassic Park Dracula Macbeth
User Idiots Music
(Adventure) (Horror) (Tragedy)
(Comedy) (Romance)

Anmol 7 9 8 6 2

Babita 2 7 9 10 6

Chester 5 4 3 7 3

Disha 9 2 5 10 8

Euclid 1 6 3 8 9

Consider the rating given by Babita. Her ratings can be represented by the ordered tuple (2, 7, 9, 10, 6),
where the first, second, third, fourth and fifth coordinates refer to the ratings given to Jurassic Park, Three
Idiots, The Sound of Music, Dracula and Macbeth, respectively. We can represent the ratings given by all
the five users in a similar manner; however, it will be difficult to visualise them.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Plotting Vectors

Plotting a vector means representing a vector by an arrow in space. The arrow connects a point by a line
from the origin. The arrowhead gives the sense of the direction of the vector.

The vector (3, 1) can be plotted as shown in the image given below.

Plotting vectors makes it easy for us to understand data.

Consider the following ratings given by five users to two movies and the corresponding plot.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
By taking a look at the graph, we can easily interpret that Anmol and Chester like Jurassic Park more than
Three Idiots, and Babita and Euclid like Three Idiots more than Jurassic Park.

If we were handling a larger set of users, this visualisation would help us understand user preferences
efficiently.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Magnitude of a Vector

Some important points related to the magnitude of a vector are as follows:

● Consider a vector 𝑢 = (𝑢1 , 𝑢2 ). The magnitude is denoted by ‖𝑢‖.

● ‖𝑢‖ = √𝑢1 2 + 𝑢2 2
● In the 𝑛-dimensional space, ‖𝑢‖ = √𝑢1 2 + 𝑢2 2 + ⋯ + 𝑢𝑛 2 .

● Consider a vector 𝑢 = (4, 3). Then, ‖𝑢‖ = √32 + 42 = √9 + 16 = √25 = 5.

Unit Vector

Some important points related to the unit vector are as follows:

● Its magnitude is unity.


● It indicates the direction of a vector.
𝑢
● The unit vector in the direction of 𝑢 is given by 𝑢̂= .
‖𝑢 ‖

Some standard unit vectors in the two-dimensional and three-dimensional space are shown below.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Zero Vector

Some important points related to the zero vector are as follows:

● The magnitude of a zero vector is 0.

● The zero vector can be denoted by 0 or 0 or 0.


● Each dimension has a unique zero vector:

o 2 dimensions, 0 = (0,0)

o 3 dimensions, 0 = (0,0,0)

o In 𝑛 dimensions, 0 = (0,0, … ,0) – 𝑛 components

Addition of Vectors

Consider the marks scored by two students Sakshi and Manas in English and Mathematics.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
The subject-wise marks scored by Manas and Sakshi can be represented by the vectors 𝑚 and 𝑠,
respectively.

If we want to know the total of the subject-wise marks scored by Sakshi and Manas we can simply add the
two vectors 𝑚 and 𝑠. The vectors 𝑚 and 𝑠 can be added as shown below.

𝑚 + 𝑠 = [50 20 ] + [20 50 ] = [50 + 20 20 + 50 ] = [70 70 ]

The following points need to be kept in mind while adding two vectors:

● Generally, when we add two vectors, we add the corresponding components as shown above.
● Both vectors should have the same dimension.
● Addition results in a third vector of the same dimension.

● The order of addition does not matter, i.e., 𝑎 + 𝑏 = 𝑏 + 𝑎.

Visualising the Addition of Vectors


Consider the following example where marks of two students Sakshi and Manas in two subjects English
and Math are as given in the table.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
The two vectors 𝑚 and 𝑠 can also be added as shown in the graph given above. The tail of the vector 𝑠 is
placed on the head of the second vector, and the resultant is obtained by joining the tail of the vector 𝑚
and the head of the vector 𝑠 .

The following figure shows the two ways to add vectors 𝑎 and 𝑏 .

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Scalar Multiplication
When we multiply a vector by a scalar, we simply multiply each of the components of the vector by that
scalar as shown in the example given below.

Multiplying a vector by a scalar can either stretch or contract the vector as shown below.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Vector Subtraction

The vector subtraction of two vectors 𝑎 and 𝑏 can be thought of as the addition of 𝑎 and −𝑏.

Dot Product or Scalar Product

Some important points related to the dot product are as follows:

● The dot product or the scalar product is a product of two vectors that gives a scalar.
● This product can be used to find the angle between two vectors.

● This product also helps to find the magnitude of a vector, i.e., ‖𝑎‖ = √𝑎. 𝑎 .
● If 𝑎 = [1 2 ] and 𝑏 = [6 15 ] , then 𝑎. 𝑏 = 1 × 6 + 2 × 15 = 36.

The following table shows the ratings given by 10 people to five movies. Suppose we are interested in the
ratings given by Euclid and want to know whose ratings are similar to the ones given by him. We consider
Anmol and Howard. So, we find the dot product between the rating vectors as shown below.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
𝑎. 𝑒 is less than ℎ. 𝑒, which implies that the ratings given by Howard are closer to the ratings given by
Euclid than those given by Anmol.

Orthogonal Vectors

Two vectors are said to be orthogonal if the angle between them is 90°.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
NORMS

Some important points related to norms are as follows:

● A norm is a function that helps in finding the distance between two vectors.
● It can also be used to calculate the magnitude of a vector.
● The norm of a vector 𝑢 is denoted by ‖𝑢‖.

𝐿2 or Euclidean Norm

Suppose a bird starts flying from (0,0) to (1,2). We want to calculate the distance travelled by this bird,
which is given by the 𝐿2 norm of (1,2).

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Distance travelled by the bird = √12 + 22 = √5 = ‖(1,2)‖2

Generally, the 𝐿2 norm of a vector gives us its distance from the origin and

‖(𝑥1, 𝑥2 … 𝑥𝑛)‖2 = √𝑥2 + 𝑥2 + 𝑥2


1 2+⋯ 𝑛

𝐿1 or Taxicab Norm or Manhattan Distance

Suppose a car starts moving from (0,0) to (1,2). Unlike the bird, the car can only travel along the
horizontal and vertical road networks. We want to calculate the distance travelled by this car, which is
given by the 𝐿1 norm of (1,2).

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Distance travelled by the car = |1| + |2| = 3 = ‖(1,2)‖1

In general, the 𝐿1 norm of a vector gives its distance from the origin and

‖(𝑥1, 𝑥2 ⋯ 𝑥𝑛)‖1 = |𝑥1| + |𝑥2| + ⋯ + |𝑥𝑛|

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
The following table shows the ratings given by 10 people to five movies. Suppose we are interested in the
ratings given by Euclid and want to know whose ratings are similar to the ones given by him. We consider
Anmol and Howard. So, we find the norm of the difference of the rating vectors as shown below.

Since ‖𝑎 − 𝑒‖ is greater than ‖ℎ − 𝑒‖, it implies that the ratings given by Howard are closer to the ratings
given by Euclid than the ones given by Anmol.

Powered by upGrad Education Private Limited


© Copyright . upGrad Education Pvt. Ltd.
All rights reserved
Powered by upGrad Education Private Limited
© Copyright . upGrad Education Pvt. Ltd. All rights reserved

Disclaimer: All content and material on the upGrad website is copyrighted material, either belonging to upGrad or
its bonafide contributors and is purely for the dissemination of education. You are permitted to access print and
download extracts from this site purely for your own education only and on the following basis:

● You can download this document from the website for self-use only.
● Any copies of this document, in part or full, saved to disc or to any other storage medium may only be used
for subsequent, self-viewing purposes or to print an individual extract or copy for non-commercial personal
use only.
● Any further dissemination, distribution, reproduction, copying of the content of the document herein or the
uploading thereof on other websites or use of the content for any other commercial/unauthorised purposes
in any way which could infringe the intellectual property rights of upGrad or its contributors, is strictly
prohibited.
● No graphics, images or photographs from any accompanying text in this document will be used separately
for unauthorised purposes.
● No material in this document will be modified, adapted or altered in any way.
● No part of this document or upGrad content may be reproduced or stored in any other web site or included
in any public or private electronic retrieval system or service without upGrad’s prior written permission.
● Any rights not expressly granted in these terms are reserved.

You might also like