Linear Algebra: Vectors

Vector operations, dot product, magnitude, unit vectors

7 free lessons available

Start here

Vector Definition (Geometric & Algebraic)

In fields ranging from physics simulations to machine learning algorithms, quantities often require more than just a single number to describe them. Consider the force applied to an object, or the velocity of an airplane. These aren't just about "how much" (magnitude); they also involve "in what direction." This is where vectors become indispensable. They provide a precise mathematical tool to represent quantities that possess both magnitude and direction.

The Geometric View: Magnitude and Direction

Geometrically, a vector is visualized as a directed line segment, or an arrow. The length of this arrow represents the vector's magnitude (or size), while the way the arrow points indicates its direction. A crucial aspect of this geometric definition is that a vector's identity is independent of its starting position. As long as its magnitude and direction remain the same, it's considered the same vector, regardless of where it originates in space.

Geometric Representation of a Free Vector
This plot shows two vectors, 'v' and 'v'', that have identical magnitude and direction but originate from different points. This illustrates that a vector's identity is defined by its length and orientation, not its starting position.
Loading chart...
Key Insight: A vector is defined by its magnitude and direction, not its starting point. 'v' and 'v'' are the same vector.
๐Ÿ’ก Vectors vs. Scalars

A scalar is a quantity described by magnitude alone (e.g., temperature, mass, speed). A vector requires both magnitude and direction (e.g., velocity, force, displacement). This distinction is fundamental in physics and engineering.

The Algebraic View: Components in a Coordinate System

While the geometric view is intuitive, for calculations and computational work, we represent vectors algebraically. An algebraic vector is an ordered list of numbers, called components, that describe the vector's displacement along each axis of a coordinate system. For instance, in a 2D Cartesian plane, a vector might be represented as (x,y)(x, y), where xx is the displacement along the x-axis and yy is the displacement along the y-axis. This representation allows us to perform precise mathematical operations.

pythonRepresenting a 2D Vector Algebraically
โœจ Column vs. Row Vectors

In linear algebra, vectors are often written as column vectors (vertical) or row vectors (horizontal). For example, a 2D vector could be

(xy)\begin{pmatrix} x \\ y \end{pmatrix}
(column) or [xy][x \quad y] (row). The choice often depends on context, especially when performing matrix multiplications.

Dimensions and Components

The number of components in a vector determines its dimension. A vector with two components, like [x,y][x, y], exists in a 2D space. A vector with three components, [x,y,z][x, y, z], exists in 3D space. In machine learning, it's common to encounter vectors with hundreds or even thousands of components, representing high-dimensional spaces where each component might correspond to a feature or attribute. The principles remain the same, regardless of the number of dimensions.

pythonRepresenting Higher-Dimensional Vectors
Check Your Understanding
What does a negative component, like -5 in a vector [2, -5], represent geometrically?

Calculating Magnitude (Length)

The magnitude of an algebraic vector, often denoted as โˆฃโˆฃvโˆฃโˆฃ||\mathbf{v}|| or โˆฃvโˆฃ|\mathbf{v}|, is its length. For a 2D vector v=[x,y]\mathbf{v} = [x, y], we calculate its magnitude using the Pythagorean theorem: x2+y2\sqrt{x^2 + y^2}. This concept extends to higher dimensions; for an n-dimensional vector v=[v1,v2,...,vn]\mathbf{v} = [v_1, v_2, ..., v_n], the magnitude is v12+v22+...+vn2\sqrt{v_1^2 + v_2^2 + ... + v_n^2}. This is also known as the Euclidean norm or L2 norm.

pythonCalculating Vector Magnitude
๐Ÿ“ Euclidean Norm (L2 Norm)

For a vector v=[v1,v2,...,vn]\mathbf{v} = [v_1, v_2, ..., v_n], its Euclidean norm (magnitude) is given by:

โˆฃโˆฃvโˆฃโˆฃ2=โˆ‘i=1nvi2||\mathbf{v}||_2 = \sqrt{\sum_{i=1}^{n} v_i^2}

Direction: Unit Vectors and Angles

While magnitude is a single number, direction is more complex. For a 2D vector, direction is often described by the angle it makes with the positive x-axis. In higher dimensions, this becomes less intuitive. A more general way to represent a vector's direction is through a unit vector. A unit vector is a vector with a magnitude of 1 that points in the same direction as the original vector. You can obtain a unit vector by dividing each component of the original vector by its magnitude.

Try It Yourself
Given the vector v = [4, -3], calculate its magnitude and then find its corresponding unit vector. Print both the magnitude and the unit vector, formatted to two decimal places.
python

Position Vectors: Fixed Starting Point

A position vector is a special type of vector that always originates from the origin of a coordinate system (e.g., (0,0)(0,0) in 2D, (0,0,0)(0,0,0) in 3D). Its components directly correspond to the coordinates of a specific point in space. For example, the position vector [3,2][3, 2] points directly to the point (3,2)(3, 2). These are particularly useful for locating points and describing their displacement from a fixed reference point, such as in GPS systems or object tracking.

Position Vector from the Origin
This plot shows a position vector 'P' originating from the coordinate system's origin (0,0) and pointing to the point (4,3). Its components directly represent the coordinates of that point.
Loading chart...
Key Insight: A position vector's tail is always at the origin, and its components are the coordinates of its tip.

Free Vectors: Flexible Starting Point

In contrast to position vectors, free vectors represent pure displacement or a physical quantity like force or velocity, independent of a specific starting location. As long as a free vector maintains its magnitude and direction, it is considered the same vector, regardless of where its tail is placed. The geometric visualization we saw earlier, with two identical vectors starting at different points, perfectly illustrates the concept of a free vector. They are useful for describing relative motion or forces acting on objects without needing to fix them to an origin.

๐Ÿ“Œ The 'Free' Aspect

The term 'free' in free vector means its starting point is arbitrary. You can translate a free vector anywhere in space, and it remains the same vector as long as its length and orientation are preserved. This makes them ideal for representing physical quantities like velocity or acceleration.

Check Your Understanding
Which characteristic is unique to a position vector compared to a free vector?
Position Vectors vs. Free Vectors
FeaturePosition VectorFree Vector
Starting PointAlways at the origin (0,0,...)Can start anywhere in space
PurposeLocates a specific point relative to originRepresents displacement, velocity, force, etc.
IdentityDefined by its endpoint coordinates (which are its components)Defined by its magnitude and direction, independent of location
Example UseCoordinates of a city on a mapVelocity of a car, force applied to an object
Understanding when to use a position vector versus a free vector is key to applying them correctly.
Key Takeaways
  • Vectors represent quantities with both magnitude (size) and direction (orientation).

  • Geometrically, a vector is an arrow; its identity is independent of its starting point (for free vectors).

  • Algebraically, a vector is an ordered list of components representing displacement along coordinate axes.

  • The dimension of a vector is determined by the number of its components.

  • Vector magnitude (Euclidean norm) is calculated using the Pythagorean theorem on its components.

  • A unit vector has a magnitude of 1 and indicates the direction of the original vector.

  • Position vectors always start at the origin and point to a specific coordinate, while free vectors can be translated anywhere without changing their identity.

Open this lesson on its own page โ†’

Ready to keep this from fading?

Bitelrn turns lessons like this into a full course โ€” quizzes, a knowledge map, and spaced review.

Get started free