Professional Documents
Culture Documents
Lecture Notes M1 S1
Lecture Notes M1 S1
Vectors can be thought of as ordered lists or tuples. They are used to store values from a data set.
● 𝑣
● 𝑣
● 𝑣
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.
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 ).
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.
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.
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.
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.
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.
Consider the following table that shows the ratings given by five users to five movies.
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.
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.
Consider the following ratings given by five users to two movies and the corresponding plot.
If we were handling a larger set of users, this visualisation would help us understand user preferences
efficiently.
● ‖𝑢‖ = √𝑢1 2 + 𝑢2 2
● In the 𝑛-dimensional space, ‖𝑢‖ = √𝑢1 2 + 𝑢2 2 + ⋯ + 𝑢𝑛 2 .
Unit Vector
Some standard unit vectors in the two-dimensional and three-dimensional space are shown below.
o 2 dimensions, 0 = (0,0)
o 3 dimensions, 0 = (0,0,0)
Addition of Vectors
Consider the marks scored by two students Sakshi and Manas in English and Mathematics.
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.
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 following figure shows the two ways to add vectors 𝑎 and 𝑏 .
Multiplying a vector by a scalar can either stretch or contract the vector as shown below.
The vector subtraction of two vectors 𝑎 and 𝑏 can be thought of as the addition of 𝑎 and −𝑏.
● 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.
Orthogonal Vectors
Two vectors are said to be orthogonal if the angle between them is 90°.
● 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).
Generally, the 𝐿2 norm of a vector gives us its distance from the origin and
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).
In general, the 𝐿1 norm of a vector gives its distance from the origin and
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.
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.