Vector Basics

Everything you need to know to get started with vectors.

5 min read Beginner

Contents

What is a Vector?

A vector is a mathematical object that has both magnitude (size) and direction. Unlike regular numbers (scalars) that only have magnitude, vectors tell us "how much" and "which way."

Real-world example: "Walk 5 meters north" is a vector - it has both a distance (5 meters) and a direction (north). Just "5 meters" by itself is a scalar.

Representing Vectors

Arrow Notation

Visually, we represent vectors as arrows. The arrow's length represents the magnitude, and the arrow points in the direction of the vector.

Interactive: Drag the vector endpoint

Position
(3.0, 4.0)
Magnitude
5.00

Component Form

In coordinate systems, we write vectors as ordered lists of numbers called components. In 2D:

\[\vec{v} = \begin{pmatrix} x \\ y \end{pmatrix} = (x, y)\]

For example, the vector \(\vec{v} = (3, 4)\) means:

  • Move 3 units in the x-direction (right)
  • Move 4 units in the y-direction (up)

3D and Higher Dimensions

Vectors can exist in any number of dimensions:

  • 2D: \(\vec{v} = (x, y)\) - position on a plane
  • 3D: \(\vec{v} = (x, y, z)\) - position in space
  • nD: \(\vec{v} = (v_1, v_2, ..., v_n)\) - used in AI/ML for embeddings

Vector Notation

Different notations are used depending on context:

Notation Example Common In
Arrow \(\vec{v}\) Physics, Mathematics
Bold v Textbooks, printed material
Component (3, 4) or [3, 4] Programming, Linear algebra
Unit vectors \(3\hat{i} + 4\hat{j}\) Physics, Engineering

Vector Magnitude

The magnitude (or length) of a vector is calculated using the Pythagorean theorem:

\[|\vec{v}| = \sqrt{x^2 + y^2}\]

For the vector (3, 4):

|v| = √(3² + 4²) = √(9 + 16) = √25 = 5

Key Properties

Vectors vs Points

While both can be written as (x, y), they represent different things:

  • Point: A specific location in space
  • Vector: A displacement (direction and magnitude) that can start anywhere
Important: Two vectors with the same components are equal, regardless of where they start. The vector (3, 4) starting at the origin is the same as (3, 4) starting at point (1, 1).

Zero Vector

The zero vector \(\vec{0} = (0, 0)\) has no magnitude and no defined direction. It's the additive identity for vectors.

Applications

Vectors are foundational to many fields:

Physics

Force, velocity, acceleration, momentum

Graphics

Positions, transformations, lighting, normals

AI/ML

Word embeddings, image features, similarity

Next Steps

Now that you understand the basics, continue with:

💡

Vectors Explained Simply

Imagine you're giving someone directions. If you just say "walk 10 steps," they don't know which way to go. But if you say "walk 10 steps toward the big tree," now they know exactly what to do!

A vector is like those complete directions. It tells you two things: how far (the number of steps) and which way (toward the tree). Regular numbers only tell you "how much" — like saying you have 5 apples. But vectors add the "which direction" part.

Think of an arrow on a treasure map. The arrow's length shows how far you need to go, and where it points shows the direction. That arrow is a vector! We write it as numbers like (3, 4), which means "go 3 steps right and 4 steps up."

Vectors are everywhere — when you kick a ball, the ball moves in a certain direction with a certain speed. That movement is a vector! Video games use vectors to know where characters are moving. Even your GPS uses vectors to guide you to your destination.

Frequently Asked Questions About Vectors

What is a vector in simple terms?
A vector is a quantity that has both a size (magnitude) and a direction. Think of it as an arrow pointing somewhere — the arrow's length tells you how much, and where it points tells you which way. For example, "5 miles north" is a vector because it includes both distance and direction.
What is the difference between a vector and a scalar?
A scalar is just a number with magnitude only (like temperature: 25°C, or mass: 10 kg). A vector has both magnitude AND direction. Speed (50 mph) is a scalar, but velocity (50 mph heading east) is a vector. Scalars answer "how much?" while vectors answer "how much and which way?"
How do you write a vector?
Vectors can be written in several ways: as an arrow over a letter (v⃗), in bold (v), or as coordinates in parentheses like (3, 4) for 2D or (1, 2, 3) for 3D. In programming, vectors are typically represented as arrays like [3, 4]. The numbers are called components and represent movement along each axis.
What are vectors used for in real life?
Vectors are used everywhere: GPS navigation (calculating direction and distance), video games (character movement, physics), weather forecasting (wind speed and direction), aviation (flight paths), robotics (arm movements), computer graphics (3D rendering), and AI/machine learning (representing data as embeddings for similarity searches).
How do you find the length of a vector?
The length (magnitude) of a vector is found using the Pythagorean theorem. For a 2D vector (x, y), the length is √(x² + y²). For example, vector (3, 4) has length √(9 + 16) = √25 = 5. For 3D vectors (x, y, z), use √(x² + y² + z²). This extends to any number of dimensions.
What is the difference between 2D and 3D vectors?
A 2D vector has two components (x, y) and exists on a flat plane — like directions on a map. A 3D vector has three components (x, y, z) and includes height/depth — like directions in a building including which floor. The math works the same way; you just add another dimension.
Can vectors have more than 3 dimensions?
Yes! Vectors can have any number of dimensions. While we can't visualize more than 3D, the math works exactly the same. In AI and machine learning, vectors often have hundreds or thousands of dimensions. For example, word embeddings might use 768-dimensional vectors to capture the meaning of words.
What is a unit vector?
A unit vector is a vector with a length (magnitude) of exactly 1. It's used to represent pure direction without any magnitude. You create a unit vector by dividing a vector by its length. Unit vectors are commonly written with a "hat" symbol, like î, ĵ, and k̂ for the x, y, and z directions.
What is the zero vector?
The zero vector is a special vector where all components are zero, written as (0, 0) in 2D or (0, 0, 0) in 3D. It has a magnitude of zero and no defined direction. The zero vector is important in math because adding it to any vector leaves that vector unchanged — it's the "identity element" for vector addition.
Why are vectors important in programming?
Vectors are fundamental in programming for game development (player movement, physics, collisions), computer graphics (3D rendering, transformations), machine learning (representing data as feature vectors, embeddings), image processing (each pixel as a color vector), and data science (multi-dimensional data analysis). Most programming languages have libraries for vector operations.