Vectors and scalars
Definitions, usage, examples
A vector is an element of a vector space. A vector space is a collection of vectors that can be added together and multiplied (“scaled”) by numbers, called scalars. Scalars are often taken to be real numbers, but there are also vector spaces with scalar multiplication by complex numbers, rational numbers, or generally any field. The operations of vector addition and scalar multiplication must satisfy certain requirements, called axioms, which ensure that vector spaces behave like the familiar space of Euclidean vectors. A vector has magnitude (or length) and direction.
A scalar also known as 1D vector is a single value, often a number, that describes a physical quantity. Unlike vectors, scalars do not have a direction. Examples of scalars include temperature, mass, and energy. Vectors and scalars are used in many fields of study to represent different types of physical quantities. In the following sections we will present the fields of application and their representation.
In physics, vectors are commonly used to represent quantities such as velocity, force, acceleration, and angular momentum. Scalars are used to represent quantities such as mass, energy, and temperature.
In engineering, vectors are used to represent quantities such as displacement, velocity, and acceleration in mechanics, and electromagnetic fields in electrical engineering. Scalars are used to represent quantities such as pressure, density, and temperature.
In computer graphics, vectors are used to represent points, normals, and directions in 3D space. Scalars are used to represent quantities such as color values and transparency.
In economics, vectors are used to represent multi-dimensional data, such as a time series of prices for multiple different goods, while scalars are used to represent single value data, such as GDP.
In machine learning, vectors are used to represent data points, such as images or text, while scalars are used to represent parameters, such as weights or biases.
In navigation, vectors are used to represent position, velocity and acceleration of moving objects, while scalars are used to represent distances, speeds, and time.
As a software developer, I will use a machine learning and computer programming approach to introduce vectors and scalars in the Python programming language. A vector can be represented as a list of numbers like this:
vector = [1, 2, 3] #3D vector
This vector has three elements, which are the numbers 1, 2, and 3. These elements can be accessed using their index in the list, just like any other list in Python. Unlike scalars, scalars can be represented in programming, for example, as single numbers:
scalar = 2
scalar = [3]
scalar = (3,)
In a program, vectors and scalars can be used in many ways. For example, you can use a vector to represent the coordinates of a point in a 2D or 3D space, and use scalars to represent the magnitudes of physical quantities such as mass or velocity. You can also perform mathematical operations on vectors and scalars in a program, such as vector addition and scalar multiplication.
#Addition
vector1 = [1, 2, 3]
vector2 = [4, 5, 6]
result = vector1 + vector2
#result [5, 7, 9]
#Multiplication by a scalar
vector = [1, 2, 3]
scalar = 2
result = vector * scalar
#result [2, 4, 6]
There are also many libraries and modules available in many programming languages that provide additional functionality for working with vectors and matrices, such as NumPy in Python. These libraries provide functions for advanced operations such as dot products, cross products, and matrix inverses, as well as tools for linear algebra and numerical computation.
In conclusion, vectors and scalars can be represented and used in programming in similar ways to how they are used in mathematics and physics, and many common operations such as addition and multiplication can be performed using standard mathematical operators.
If you like the article, be sure to follow me to catch my new articles.