Chapter 1
15 min read
Section 2 of 134

Vectors as Arrows vs Vectors as Lists

The Geometric Universe

Learning Objectives

By the end of this section, you will:

  • Understand the three ways to think about vectors: as arrows in space (physics), as ordered lists of numbers (computer science), and as abstract objects obeying axioms (mathematics)
  • See how these perspectives are not competing but complementary, and why fluency in both the arrow picture and the list picture is essential for mastering linear algebra
  • Grasp the central role of basis vectors as the bridge between geometric arrows and numerical coordinates
  • Understand linear combinations as the single most fundamental operation in all of linear algebra
  • Explore span: the set of all points reachable by linear combinations of a set of vectors
  • See how changing the basis changes the coordinates but never the vector itself, building the deep intuition that coordinates are a choice, not a fact
  • Recognize how vectors appear in physics, engineering, computer graphics, data science, and machine learning

Why This Matters

Every concept in linear algebra, from matrix multiplication to eigenvalues to SVD, builds on the idea of vectors and linear combinations. Getting these foundations right is like learning the alphabet before reading: everything that follows becomes vastly easier once you can fluidly move between the geometric and algebraic pictures of vectors.

The Big Picture: Three Perspectives on Vectors

Ask three people what a vector is, and you may get three different answers. A physics student will say it is an arrow with direction and magnitude. A computer science student will say it is an ordered list of numbers. A mathematician will say it is any object that can be added together and scaled according to certain rules. All three are correct. Understanding their relationship is the first great insight of linear algebra.

The Physics Student's Vector

In physics, a vector is an arrow in space. It has two properties: a direction (which way it points) and a magnitude (how long it is). A force is a vector. A velocity is a vector. An electric field at a point is a vector.

In this picture, a vector is defined by where it points and how far it reaches, not by where it starts. Two arrows with the same direction and length represent the same vector, even if they are drawn in different places. However, in linear algebra we adopt a convention: every vector starts at the origin. This small restriction gives us a fixed reference point and makes the connection to coordinates possible.

Key insight: In the arrow picture, a vector exists independent of any coordinate system. It is a geometric object, as real as a line or a circle. Coordinates are how we describe it, not what it is.

The Computer Scientist's Vector

In computer science, a vector is an ordered list of numbers. A 2D vector is a pair (x,y)(x, y). A 3D vector is a triple (x,y,z)(x, y, z). A vector in nn dimensions is a list of nn numbers.

This is the view that computers use. In NumPy, a vector is a 1D array. In a database, a feature vector is a row of numbers. In a neural network, an embedding is a list of floating-point values. The list picture is powerful because it is directly computable: you can store vectors in memory, loop over their entries, and perform arithmetic entry by entry.

The list picture makes some things obvious that the arrow picture obscures. For example, a vector can have 768 dimensions (like a word embedding in a language model), which is impossible to visualize as an arrow but perfectly natural as a list of 768 numbers.

The Mathematician's Vector

A mathematician defines a vector as any object that lives in a vector space: a set of objects that can be added together and multiplied by scalars, where these operations satisfy certain axioms (closure, associativity, commutativity of addition, existence of a zero vector, and so on).

Under this definition, arrows in the plane are vectors. Lists of numbers are vectors. But so are polynomials, functions, matrices, and even random variables. This abstraction is what gives linear algebra its universal power: any system that obeys the axioms of a vector space can be analyzed with the same tools.

The Three Perspectives Work Together

The arrow picture gives geometric intuition: you can see directions, angles, and areas. The list picture gives computational power: you can run algorithms. The abstract picture gives universal applicability: the same theorems work in any vector space. A complete understanding requires all three.

The Arrow Picture: Vectors in Space

Let us begin with the arrow picture and develop it carefully. Imagine standing at the origin of a 2D coordinate system. A vector v\mathbf{v} is an arrow from the origin to some point in the plane. The arrow encodes two pieces of information simultaneously:

  • Direction: The angle the arrow makes with the positive x-axis, measured counterclockwise. A vector pointing straight right has direction 00^\circ; a vector pointing straight up has direction 9090^\circ.
  • Magnitude: The length of the arrow, written v\|\mathbf{v}\|. For a vector v=(x,y)\mathbf{v} = (x, y), the magnitude is v=x2+y2\|\mathbf{v}\| = \sqrt{x^2 + y^2} by the Pythagorean theorem.

Explore two vectors on a coordinate grid. Drag the arrow tips or use the sliders to change the yellow vector v\vec{v} and cyan vector w\vec{w}. Watch how the bracket notation updates as you move them:

-8-7-6-5-4-3-2-112345678-6-5-4-3-2-1123456032v-24w
v= 3 î + 2 ĵ
|v|=3.61 · 33.7°
3
2
w= -2 î + 4 ĵ
|w|=4.47 · 116.6°
-2
4

Drag the circle at each arrow tip or use the sliders · dashed red = î component · dashed green = ĵ component

The interactive visualization below lets you explore this duality. Drag the arrow tip or use the sliders, and watch how the geometric properties (direction, magnitude) and the algebraic properties (the list of numbers) update in lockstep. Toggle the decomposition to see how the vector breaks into its x-component (horizontal) and y-component (vertical).

Interactive: The Dual Nature of Vectors

Drag the arrow tip to move the vector. The arrow and the list of numbers are two faces of the same object.

xy3.02.0v
The Arrow View
Direction: 33.7°
Magnitude: 3.61
The List View
[
3.02.0
]
x-component & y-component
Try These

The green arrow and the red/blue numbers describe the same object. The arrow gives direction and magnitude; the list gives precise coordinates. Neither view is more "real" — they are two languages for the same idea.

Notice something profound: the xx-component (how far right) and the yy-component (how far up) completely determine the arrow. Given these two numbers, you can reconstruct the arrow exactly. And given the arrow, you can read off the two numbers. The arrow and the pair of numbers carry exactly the same information.


The List Picture: Vectors as Coordinates

Now let us look at the list picture more carefully. A vector in Rn\mathbb{R}^n is an ordered nn-tuple of real numbers:

v=(v1v2vn)\displaystyle \mathbf{v} = \begin{pmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{pmatrix}

Each entry viv_i is called a component of the vector. In 2D, we write v=(v1,v2)\mathbf{v} = (v_1, v_2) or equivalently as a column. In 3D, v=(v1,v2,v3)\mathbf{v} = (v_1, v_2, v_3).

But here is the key question: what do these numbers actually mean? The number v1=3v_1 = 3 means "go 3 units in the first direction." The number v2=2v_2 = 2 means "go 2 units in the second direction." But what are these "directions"? They are the basis vectors, and this brings us to the most important idea in this entire section.


The Bridge: Basis Vectors and Coordinates

The connection between arrows and lists is not arbitrary. It is built on a choice: the choice of basis vectors. Basis vectors are the rulers against which everything is measured. They are the "units" of your coordinate system.

Meet ı^\hat{\imath} and ȷ^\hat{\jmath}

In 2D, the standard basis consists of two special vectors:

  • ı^=(1,0)\hat{\imath} = (1, 0): a unit vector pointing to the right along the x-axis
  • ȷ^=(0,1)\hat{\jmath} = (0, 1): a unit vector pointing upward along the y-axis

These two vectors, often written e1\mathbf{e}_1 and e2\mathbf{e}_2, are perpendicular and each has length 1. Together, they define what "right" and "up" mean in our coordinate system.

-3-3-2-2-1-11122330î10ĵ01

Coordinates as Instructions

Here is the central insight, the one that 3Blue1Brown calls the most important idea in linear algebra:

The Fundamental Interpretation of Coordinates

The coordinates of a vector are instructions for how to combine the basis vectors. The vector v=(3,2)\mathbf{v} = (3, 2) means: take 3 copies of ı^\hat{\imath} and 2 copies of ȷ^\hat{\jmath}, then add them together. Symbolically: v=3ı^+2ȷ^\mathbf{v} = 3\hat{\imath} + 2\hat{\jmath}.

This is a linear combination of the basis vectors. The numbers 3 and 2 are the scalars (or coefficients) that tell you how much of each basis vector to use. The result is the vectorv\mathbf{v}.

-4-4-3-3-2-2-1-1112233440îĵv32

In general, any vector in 2D can be written as:

v=v1ı^+v2ȷ^=v1(10)+v2(01)=(v1v2)\displaystyle \mathbf{v} = v_1 \hat{\imath} + v_2 \hat{\jmath} = v_1 \begin{pmatrix} 1 \\ 0 \end{pmatrix} + v_2 \begin{pmatrix} 0 \\ 1 \end{pmatrix} = \begin{pmatrix} v_1 \\ v_2 \end{pmatrix}

The list (v1,v2)(v_1, v_2) is just shorthand for the linear combination v1ı^+v2ȷ^v_1 \hat{\imath} + v_2 \hat{\jmath}. The list is the instructions; the arrow is the result of following those instructions.

Different Basis, Different Numbers

Here is where things get deep. The numbers in the list depend on which basis you chose. If you pick different basis vectors, the same arrow in space will have different coordinates.

Suppose instead of ı^\hat{\imath} and ȷ^\hat{\jmath}, you use basis vectors b1=(1,0.5)\mathbf{b}_1 = (1, 0.5) and b2=(0.5,1)\mathbf{b}_2 = (-0.5, 1). The same geometric arrow that was (3,2)(3, 2) in the standard basis will have different coordinates in this new basis. The arrow hasn't moved. Only the numbers describing it have changed, because the rulers changed.

The interactive demo below shows this vividly. The green arrow is the same vector in both views. But the coordinates differ because the basis vectors differ.

Interactive: Same Vector, Different Coordinates

The green arrow is the same vector in both views. Only the coordinates change when you change the basis.

Standard Basis
îĵ
[3.00,2.00]
coordinates in this basis
Custom Basis
b₁b₂
[3.20,0.40]
coordinates in this basis
Target Vector
Custom Basis

The vector (the arrow in space) never changes. Only the numbers we use to describe it change when we pick a different basis. Coordinates are not intrinsic to the vector — they depend on the language (basis) we choose.

Why This Matters for AI

In machine learning, changing the basis is central to techniques like PCA (Principal Component Analysis), where you find new axes that capture the most variance in your data. The data points don't move; they just get described in a more informative coordinate system. Understanding that coordinates are relative to a basis is essential for understanding dimensionality reduction, feature engineering, and representation learning.

Vector Operations in Both Pictures

Two operations define the structure of vectors: addition and scalar multiplication. Both have clean geometric and algebraic descriptions.

Addition: Geometric and Algebraic

Geometrically, vector addition follows the tip-to-tail rule: place the tail of v\mathbf{v} at the tip of u\mathbf{u}, and the sum u+v\mathbf{u} + \mathbf{v} is the arrow from the origin of u\mathbf{u} to the tip of v\mathbf{v}. Equivalently, the sum is the diagonal of the parallelogram formed by the two vectors.

Algebraically, vector addition is component-wise. Each component of the sum is the sum of the corresponding components:

(u1u2)+(v1v2)=(u1+v1u2+v2)\displaystyle \begin{pmatrix} u_1 \\ u_2 \end{pmatrix} + \begin{pmatrix} v_1 \\ v_2 \end{pmatrix} = \begin{pmatrix} u_1 + v_1 \\ u_2 + v_2 \end{pmatrix}
-5-5-4-4-3-3-2-2-1-111223344550u13v31u+v44

Why do these two pictures agree? Because u+v=(u1ı^+u2ȷ^)+(v1ı^+v2ȷ^)=(u1+v1)ı^+(u2+v2)ȷ^\mathbf{u} + \mathbf{v} = (u_1 \hat{\imath} + u_2 \hat{\jmath}) + (v_1 \hat{\imath} + v_2 \hat{\jmath}) = (u_1 + v_1)\hat{\imath} + (u_2 + v_2)\hat{\jmath}. The algebra mirrors the geometry exactly.

Scalar Multiplication: Geometric and Algebraic

Geometrically, multiplying a vector v\mathbf{v} by a scalar cc stretches (or compresses) the arrow by a factor of c|c|. If c>0c > 0, the direction stays the same. If c<0c < 0, the arrow flips to point in the opposite direction. If c=0c = 0, the arrow collapses to a point at the origin (the zero vector).

Algebraically, scalar multiplication multiplies every component:

c(v1v2)=(cv1cv2)\displaystyle c \begin{pmatrix} v_1 \\ v_2 \end{pmatrix} = \begin{pmatrix} c \cdot v_1 \\ c \cdot v_2 \end{pmatrix}
-5-5-4-4-3-3-2-2-1-111223344550v212v42−v-2-1½v

Explore both operations interactively. Toggle between addition mode and scalar multiplication mode to see each operation in both pictures at once:

Interactive: Vector Operations

v₁v₂v₁+v₂
Vector v₁
Vector v₂
Result: v₁ + v₂
(3.0, 3.0)

The green arrow is the sum v₁ + v₂, reached by placing vectors tip-to-tail. The dashed lines show the parallelogram law.

OperationArrow PictureList Picture
AdditionTip-to-tail or parallelogram diagonalAdd corresponding components
Scalar mult.Stretch/shrink/flip the arrowMultiply every component by the scalar
Zero vectorA point at the origin (no direction, no length)A list of all zeros: (0, 0, ..., 0)
NegationFlip the arrow 180°Negate every component: (-v₁, -v₂)

Linear Combinations: The Fundamental Operation

We now arrive at the single most important operation in linear algebra. Given vectors v1,v2,,vk\mathbf{v}_1, \mathbf{v}_2, \ldots, \mathbf{v}_k and scalars c1,c2,,ckc_1, c_2, \ldots, c_k, their linear combination is:

c1v1+c2v2++ckvk=i=1kcivi\displaystyle c_1 \mathbf{v}_1 + c_2 \mathbf{v}_2 + \cdots + c_k \mathbf{v}_k = \sum_{i=1}^{k} c_i \mathbf{v}_i

Every concept in linear algebra can be described in terms of linear combinations:

  • A vector (3,2)(3, 2) is a linear combination of the basis vectors: 3ı^+2ȷ^3\hat{\imath} + 2\hat{\jmath}
  • A matrix-vector product AxA\mathbf{x} is a linear combination of the columns of AA, with the entries of x\mathbf{x} as scalars
  • A system of equations asks: can we write a given vector as a linear combination of other vectors?
  • Linear dependence means one vector can be written as a linear combination of the others

Consider a concrete example: 2v1+1v22\mathbf{v}_1 + 1\mathbf{v}_2 where v1=(2,1)\mathbf{v}_1 = (2, 1) and v2=(1,2)\mathbf{v}_2 = (-1, 2). The dashed arrows show the scaled contributions that add tip-to-tail to produce the result:

-5-5-4-4-3-3-2-2-1-111223344550v₁21v₂-12result34

The interactive explorer below lets you experiment freely. You have two basis vectors b1\mathbf{b}_1 and b2\mathbf{b}_2 and two scalar sliders c1c_1 and c2c_2. The result vector is c1b1+c2b2c_1 \mathbf{b}_1 + c_2 \mathbf{b}_2. By adjusting the scalars, you can reach any point in the plane. Try different basis vectors to see how the "grid" reshapes itself.

Interactive: Linear Combinations

Every vector in the plane is a linear combination of the basis vectors. Adjust the scalars to reach any point.

b₁b₂2.0b₁1.5b₂v
Scalar c₁ = 2.0
c₁ · b₁ = (2.0, 0.0)
Scalar c₂ = 1.5
c₂ · b₂ = (0.0, 1.5)
Result: c₁b₁ + c₂b₂
= (2.0, 1.5)
Basis Presets
Custom Basis

The green result vector is always c₁ · b₁ + c₂ · b₂. Try different bases to see how the same point can be reached with different combinations.

The Core Insight

When you write v=3ı^+2ȷ^\mathbf{v} = 3\hat{\imath} + 2\hat{\jmath}, the numbers 3 and 2 are instructions: "scale the first basis vector by 3, scale the second by 2, add them." The result is a point in the plane. Different instructions (different scalars) reach different points. Different basis vectors (different rulers) mean different instructions reach the same point.

Span: What Linear Combinations Can Reach

Given a set of vectors, the span is the set of all vectors that can be expressed as their linear combinations. Formally:

span(v1,v2)={c1v1+c2v2c1,c2R}\displaystyle \text{span}(\mathbf{v}_1, \mathbf{v}_2) = \{c_1 \mathbf{v}_1 + c_2 \mathbf{v}_2 \mid c_1, c_2 \in \mathbb{R}\}

The span tells us the reach of our vectors. What can we build from them? The answer depends on whether the vectors point in genuinely different directions:

  1. If v1\mathbf{v}_1 and v2\mathbf{v}_2 point in different directions (they are linearly independent), their span is the entire plane R2\mathbb{R}^2. Every point is reachable.
  2. If they point in the same (or opposite) direction (they are collinear or linearly dependent), their span is just a line through the origin. You cannot escape that line no matter what scalars you choose.
  3. If both are the zero vector, the span is just the origin, a single point.

Compare two cases side by side. On the left, independent vectors span the full plane. On the right, collinear vectors only span a line:

Independent: span = entire plane

-4-4-3-3-2-2-1-1112233440v₁21v₂-12

Dependent: span = a line

-5-5-4-4-3-3-2-2-1-111223344550v₁12v₂24

Explore this interactively in the visualization below. Start with two independent vectors (span = plane), then make them collinear and watch the span collapse to a line. The determinant indicator tells you whether the vectors are independent.

Interactive: Span of Two Vectors

The span is the set of all points reachable by linear combinations of the two vectors. Make them collinear to see the span collapse to a line.

v₁v₂
Vector v₁
Vector v₂
Span = Entire Plane
Vectors are linearly independent. Every point is reachable.
det = 4.000 (independent)
Scenarios

The purple region shows the span. When vectors point in independent directions, the span is the full plane. When they are collinear (one is a scalar multiple of the other), the span collapses to a single line.

The concept of span generalizes naturally to higher dimensions. In R3\mathbb{R}^3:

  • The span of one nonzero vector is a line (1D)
  • The span of two independent vectors is a plane through the origin (2D)
  • The span of three independent vectors is all of R3\mathbb{R}^3 (3D)

Span and Solvability

When we ask "can this system of equations be solved?", we are really asking: "is the target vector in the span of the columns of the coefficient matrix?" This geometric perspective on algebra is one of the most powerful ideas you will encounter in this book.

Higher Dimensions: Beyond What We Can See

Everything we have discussed in 2D extends naturally to nn dimensions. A vector in Rn\mathbb{R}^n is a list of nn numbers, or equivalently, a linear combination of nn standard basis vectors e1,e2,,en\mathbf{e}_1, \mathbf{e}_2, \ldots, \mathbf{e}_n:

v=v1e1+v2e2++vnen\displaystyle \mathbf{v} = v_1 \mathbf{e}_1 + v_2 \mathbf{e}_2 + \cdots + v_n \mathbf{e}_n

We lose the ability to visualize these vectors as arrows when n>3n > 3, but the algebra works identically. Addition is still component-wise. Scalar multiplication still multiplies every component. Linear combinations still combine vectors with scalar coefficients. This is the power of the list picture: it works perfectly in any number of dimensions.

DimensionWhat a Vector RepresentsExample
2A point in the planePosition on a map: (lat, lon)
3A point in spaceRGB color: (255, 128, 0)
4Beyond spatial visualizationSpacetime event: (x, y, z, t)
100A feature vector in MLMovie ratings by 100 critics
768A word embeddingBERT representation of a word
12,288A token embedding in GPT-4Every word, encoded as 12K numbers

Each component represents one degree of freedom, one independent axis along which the vector can vary. A 768-dimensional embedding vector has 768 independent "dials" that can be tuned to represent different meanings. You cannot draw this as an arrow, but the linear algebra is exactly the same as in 2D.

Before we lose the ability to visualize, let us explore 3D thoroughly. The interactive 3D explorer below lets you rotate the view freely and see vectors, linear combinations, and span in three dimensions. Switch between modes to see how a single scaled vector traces a line, how three vectors combine tip-to-tail in 3D, and how the span of three independent vectors fills all of R3\mathbb{R}^3 while dependent vectors only span a plane or line.

3D Vector Explorer
See vectors, linear combinations, and span in three dimensions.
Mode
Vectors
c1=1.50c_1 = 1.50
c2=1.00c_2 = 1.00
c3=0.80c_3 = 0.80
v1=[1.0,0.0,0.0]v_1 = [1.0, 0.0, 0.0]v2=[0.0,1.0,0.0]v_2 = [0.0, 1.0, 0.0]v3=[0.0,0.0,1.0]v_3 = [0.0, 0.0, 1.0]result = [1.50, 1.00, 0.80]

Now try manipulating individual 3D vectors directly. The interactive grid below works just like the 2D version you used earlier, but with an added zz-axis. Each vector decomposes into three basis components: ı^\hat{\imath} (red, along xx), ȷ^\hat{\jmath} (green, along yy), and k^\hat{k} (blue, along zz). Drag to orbit the scene and use the sliders to adjust each component.

3D Vector Explorer
Drag each vector tip to move it. Hold Shift while dragging to snap. Toggle decomposition to see the i/j/k components.
v= 3 î + 2 ĵ + 1 k̂
|v|=3.74
3
2
1
w= -1 î + 1 ĵ + 2.5 k̂
|w|=2.87
-1
1
2.5

Drag tips to move · red dashed = î · green dashed = ĵ · blue dashed = k̂

3D Intuition for Higher Dimensions

In 3D, three independent vectors span the entire space, just as two independent vectors span the entire plane in 2D. In R768\mathbb{R}^{768}, you need 768 independent vectors to span the space. The algebra is identical; only our ability to visualize changes. The 3D explorer above is the last dimension where your geometric intuition and the algebra can work together visually. Treasure it.

Real-World Examples Across Fields

Vectors are not abstract curiosities. They are the natural language for representing structured information in virtually every quantitative field.

Physics: Forces and Equilibrium

In physics, forces are vectors. When multiple forces act on an object, the net force is their vector sum. An object is in equilibrium when the sum of all force vectors is zero: Fi=0\sum \mathbf{F}_i = \mathbf{0}. This is a linear combination set equal to zero, one of the most basic setups in linear algebra.

-5-5-4-4-3-3-2-2-1-111223344550F₁31F₂-13F₃-2-4

Computer Graphics: Position, Color, and Motion

In 3D graphics, everything is a vector. Vertex positions are vectors in R3\mathbb{R}^3. Colors are vectors in R3\mathbb{R}^3 (RGB) or R4\mathbb{R}^4 (RGBA). Surface normals, light directions, and camera orientations are all vectors. Animation is the art of interpolating between vector-valued keyframes, which is itself a linear combination.

Economics: Price Vectors and Resource Allocation

In economics, a price vector p=(p1,p2,,pn)\mathbf{p} = (p_1, p_2, \ldots, p_n) lists the prices of nn goods. A consumption bundle q=(q1,q2,,qn)\mathbf{q} = (q_1, q_2, \ldots, q_n) lists quantities consumed. The total cost is the dot product pq=piqi\mathbf{p} \cdot \mathbf{q} = \sum p_i q_i, connecting vectors directly to economic value.

Signal Processing: Sound as Vectors

A digitized audio signal is a vector in Rn\mathbb{R}^n where nn is the number of samples. At 44.1 kHz, one second of audio is a vector with 44,100 components. Noise reduction, compression, and equalization are all linear operations on these vectors.

Data Science: Feature Vectors

In data science, each data point is a feature vector. A house might be described by the vector (sqft,bedrooms,age,price)(\text{sqft}, \text{bedrooms}, \text{age}, \text{price}). A dataset with 10,000 houses and 4 features is a collection of 10,000 vectors in R4\mathbb{R}^4. Machine learning algorithms operate on these vectors: measuring distances between them, projecting them, clustering them, and transforming them.


Vectors in Modern Machine Learning

In modern ML, vectors are not just a convenience; they are the fundamental unit of information. Understanding how vectors work gives you direct insight into how AI systems represent and process knowledge.

Word Embeddings: Meaning as Geometry

Modern NLP represents words as vectors in high-dimensional space. The famous Word2Vec and GloVe models discovered that semantic relationships become geometric relationships. The vector arithmetic kingman+womanqueen\text{king} - \text{man} + \text{woman} \approx \text{queen} works because the "gender direction" is approximately a consistent vector that can be added or subtracted. This is vector addition in a 300-dimensional space.

Neural Network Layers: Linear Combinations of Features

Each neuron in a neural network computes a linear combination of its inputs: z=w1x1+w2x2++wnxn+bz = w_1 x_1 + w_2 x_2 + \cdots + w_n x_n + b. This is exactly z=wx+bz = \mathbf{w} \cdot \mathbf{x} + b, a dot product (a special linear combination) plus a bias. A layer with mm neurons computes mm linear combinations simultaneously, which is a matrix-vector product z=Wx+b\mathbf{z} = W\mathbf{x} + \mathbf{b}.

Feature Spaces and Representations

Deep learning works by transforming input vectors through successive layers, each producing a new vector in a different representation space. An image starts as a vector of pixel values (say, in R784\mathbb{R}^{784} for a 28×28 image). The first layer might map it to R256\mathbb{R}^{256}, the next to R128\mathbb{R}^{128}, and so on. Each transformation is (approximately) a linear combination of the previous features, followed by a nonlinearity.

Similarity as Geometry

In recommendation systems and search engines, similarity between items is measured by the geometric relationship between their vectors. The cosine similarity between two vectors measures the cosine of the angle between them, which is a direct consequence of the arrow picture of vectors. Two vectors pointing in the same direction (cosine near 1) represent similar items; perpendicular vectors (cosine near 0) are unrelated.


The Computational View

Let us see vectors in action with Python and NumPy. This code demonstrates the duality between the arrow picture and the list picture, and explores linear combinations and span:

Vectors: Arrows, Lists, and Linear Combinations
🐍vectors_dual_view.py
4The List Picture

A vector is created as a NumPy array: a list of two numbers. This is the CS perspective. The numbers (3, 2) are the components.

7Arrow Properties from the List

We compute the magnitude (length) and direction (angle) from the components. np.linalg.norm computes √(x² + y²), and np.arctan2 gives the angle. This shows how to go from list → arrow.

13Reconstructing the List from Arrow Properties

We rebuild the vector from its magnitude and angle using trigonometry: x = r·cos(θ), y = r·sin(θ). This shows how to go from arrow → list. The round-trip confirms the two views carry identical information.

23Linear Combination of Basis Vectors

The vector (3, 2) is literally 3×î + 2×ĵ. This is the bridge between arrows and lists: the coordinates ARE the scalars in a linear combination of basis vectors.

30Change of Basis

We define a new basis and solve B·c = v to find the coordinates of the same vector in the new basis. np.linalg.solve finds the scalars c1, c2 such that c1·b1 + c2·b2 = v. The vector hasn’t changed; only the numbers describing it changed.

40Span and Linear Independence

The determinant of the matrix formed by two vectors tells us if they are linearly independent. Nonzero det → span is the full plane. Zero det → span is just a line. This connects the geometric concept of “can we reach every point?” to a simple number.

52 lines without explanation
1import numpy as np
2
3# A vector as a list of numbers
4v = np.array([3.0, 2.0])
5print(f"Vector v = {v}")
6
7# Arrow properties from the list
8magnitude = np.linalg.norm(v)
9angle_rad = np.arctan2(v[1], v[0])
10angle_deg = np.degrees(angle_rad)
11print(f"Magnitude: {magnitude:.3f}")
12print(f"Direction: {angle_deg:.1f} degrees")
13
14# Reconstruct from arrow properties
15v_rebuilt = magnitude * np.array([
16    np.cos(angle_rad),
17    np.sin(angle_rad)
18])
19print(f"Rebuilt from arrow: {v_rebuilt}")
20print(f"Same vector? {np.allclose(v, v_rebuilt)}")
21
22# Standard basis vectors
23i_hat = np.array([1.0, 0.0])
24j_hat = np.array([0.0, 1.0])
25
26# v as a linear combination of basis vectors
27v_from_basis = 3.0 * i_hat + 2.0 * j_hat
28print(f"\n3*i_hat + 2*j_hat = {v_from_basis}")
29print(f"Same as v? {np.allclose(v, v_from_basis)}")
30
31# Change of basis: same vector, different coordinates
32b1 = np.array([1.0, 0.5])   # new basis vector 1
33b2 = np.array([-0.5, 1.0])  # new basis vector 2
34
35# Find coordinates in new basis: solve B @ c = v
36B = np.column_stack([b1, b2])
37c = np.linalg.solve(B, v)
38print(f"\nIn standard basis: {v}")
39print(f"In custom basis:   {c}")
40
41# Verify: c[0]*b1 + c[1]*b2 should equal v
42v_check = c[0] * b1 + c[1] * b2
43print(f"Reconstructed:     {v_check}")
44print(f"Same vector? {np.allclose(v, v_check)}")
45
46# Span check: are two vectors linearly independent?
47v1 = np.array([2.0, 1.0])
48v2 = np.array([-1.0, 1.5])
49det = np.linalg.det(np.column_stack([v1, v2]))
50print(f"\ndet([v1, v2]) = {det:.3f}")
51print(f"Span = {'R^2 (full plane)' if abs(det) > 1e-10 else 'line (dependent)'}")
52
53# Collinear case
54v3 = np.array([1.0, 2.0])
55v4 = np.array([2.0, 4.0])  # v4 = 2 * v3
56det2 = np.linalg.det(np.column_stack([v3, v4]))
57print(f"det([v3, v4]) = {det2:.3f}")
58print(f"Span = {'R^2 (full plane)' if abs(det2) > 1e-10 else 'line (dependent)'}")

Summary and Road Ahead

Let us consolidate the key ideas from this section:

  1. Three perspectives on vectors: arrows in space (geometry), lists of numbers (computation), and abstract objects in vector spaces (universal theory). All three are correct and complementary.
  2. Basis vectors are the bridge between the arrow and list pictures. Coordinates are instructions for how to combine basis vectors: v=v1ı^+v2ȷ^\mathbf{v} = v_1 \hat{\imath} + v_2 \hat{\jmath}.
  3. Coordinates depend on the basis. The same arrow has different numbers in different coordinate systems. Coordinates are a choice, not an intrinsic property of the vector.
  4. Linear combinations are the fundamental operation: scale vectors and add them. Every major concept in linear algebra (matrix products, systems of equations, eigenvalue decompositions) is a variation on this theme.
  5. Span is the set of all vectors reachable by linear combinations. Independent vectors span the full space; dependent vectors span only a lower-dimensional subspace.
  6. Higher dimensions work identically to 2D and 3D algebraically, even though we can no longer visualize them. This is the power of the list picture: it scales to any dimension.
  7. Vectors are everywhere: in physics (forces), graphics (positions, colors), economics (prices), signal processing (audio), data science (features), and AI (embeddings, layer outputs, attention).

In the next section, we will explore the power of linearity: why the constraint that operations preserve addition and scaling is not a limitation but rather the source of linear algebra's extraordinary power. We will see how linearity enables decomposition, superposition, and the representation of complex transformations as simple matrices.

The key takeaway: A vector is simultaneously a geometric object (an arrow) and an algebraic object (a list of numbers). Neither description is more real than the other. The bridge between them is the choice of basis. Learning to think fluently in both pictures, switching between them depending on what question you are asking, is the first and most important skill in linear algebra.

Loading comments...