Vector spaces: build direction from addition and scaling

Learn vector spaces through robot displacement. Explore span, linear independence, basis, and dimension with an interactive diagram, Python, and exercises.

By 9 min read

What you will learn

  • Add and scale vectors to calculate a planar displacement.
  • Explain how span, independence, basis, and dimension fit together.
  • Distinguish displacement vectors from position points and robot orientations.

Before you start

  • Arithmetic with positive and negative numbers
  • Coordinates on an x-y plane

Two independent movement directions can describe every displacement on a flat floor. Point both along the same line, and their combinations stay on that line. Adding a second arrow only helps when it contributes a new direction.

Vector spaces give that idea a precise language. Span describes what combinations can reach. Independence tells you whether a direction adds anything new, and a basis gives each vector a unique set of coordinates.

We will use two-dimensional displacement vectors first, then separate them from the positions and orientations of a robot.

Start with two operations

A real vector space is a set equipped with vector addition and multiplication by real numbers. These operations must stay inside the set and obey the vector-space rules.

For ordinary coordinate vectors, add matching components:

(2, 1) + (−1, 3) = (1, 4)

A scalar is a single number. Multiplying a vector by a scalar multiplies every component:

−2(2, 1) = (−4, −2)

The rules extend familiar arithmetic:

  • Addition is commutative and associative. Every vector has an additive inverse, and adding the zero vector leaves it unchanged.
  • Multiplying by 1 leaves a vector unchanged. Two successive scalings combine by multiplying their scalars.
  • Scaling distributes over vector addition and scalar addition.

The set R² contains every pair of real numbers and satisfies these rules. Restricting both coordinates to positive numbers breaks them: multiplying by −1 leaves that set. The negative and zero cases matter as much as the positive ones.

Find what the vectors can reach

Scaling two vectors and adding the results creates a linear combination:

r = a u + b v

The span of u and v is the set of every result you can make by allowing a and b to be any real numbers. One chosen pair of coefficients gives one result; the span includes all possible choices. Interactive Linear Algebra develops this definition through vector equations.

On a plane, two vectors give three possibilities:

  • Two independent directions span the whole plane.
  • Two dependent vectors, with at least one nonzero, span a line through the origin.
  • Two zero vectors span only the zero vector.

A span is a subspace: adding or scaling its members keeps you inside it. The line y = 2x is a subspace of R². The shifted line y = 2x + 1 excludes the zero vector and fails that test.

Watch the span change

Start with “Robot displacement.” Move the coefficients while leaving u and v fixed. The result changes, while the span remains the whole plane.

Interactive experiment

What can these two vectors reach?

Change the vectors, then change their coefficients. The amber arrow is a u + b v.

Linear combinations of two planar vectorsVector u is (1, 0) and v is (0.6, 0.8). With coefficients 2 and 1, the result is (2.60, 0.80). The span has dimension 2. The two independent vectors span the whole plane.-3-3-2-2-1-1112233xysumuv
Solid u and dashed v set the directions. The thick path adds a u, then b v. Amber marks the sum and the span.

The two independent vectors span the whole plane. Current sum: (2.60, 0.80).

The controls show a bounded sample. The span allows every real coefficient, including values beyond these sliders.

Result a u + b v
(2.60, 0.80)
Span dimension
2
Basis of R²
Yes

Choose “Dependent directions.” Both vectors now follow the same line. Every coefficient choice keeps the result on that line, even when a negative coefficient reverses a movement.

Choose “Zero vectors.” Every result is zero. Then return to “Independent directions” and set both coefficients to zero: the current result is zero, but the two input vectors still span the plane.

The sliders explore a bounded range of coefficients. The mathematical span allows all real coefficients and extends beyond the visible chart.

Choose a basis without redundant directions

Vectors are linearly independent when the only way to combine them into zero uses all-zero coefficients. For two vectors, that means a u + b v = 0 forces a = b = 0.

If v = 2u, then 2u − v = 0 uses nonzero coefficients. The vectors are dependent. You can also build 3u as either 3u + 0v or u + v, so the coefficients are not unique.

A basis is an independent set that spans the space you want to describe. Every vector in that space has exactly one representation in that basis. A basis can use slanted directions; perpendicularity is optional.

The dimension counts the vectors in a basis. R² has dimension 2, a line through the origin has dimension 1, and the zero subspace has dimension 0. MIT's lecture connects independence, bases, and dimension.

Put u and v into the columns of a matrix. Its rank is the dimension of their span. The rank and null space lesson connects this count to reachable outputs and input directions that disappear.

If the vectors line up while at least one stays nonzero, the rank drops from two to one. Each column still contains two coordinates.

A matrix can also describe a linear transformation. Matrix multiplication shows how its columns determine the output and how two transformations compose. The eigenvalues lesson then finds directions that a matrix stretches, reverses, or sends to zero.

Combine two robot displacements

Suppose two displacement vectors, expressed in the same fixed map frame, are u = (1, 0) meters and v = (0.6, 0.8) meters. Take twice u, followed by once v:

2u + v = (2, 0) + (0.6, 0.8) = (2.6, 0.8) m

Draw the second displacement from the tip of the first. The total runs from the initial tail to the final tip. Reversing the addition order gives the same total displacement.

These two directions form a basis of R². For any target displacement (x, y), the second coordinate requires b = y / 0.8. The first then gives a = x − 0.6b.

For (2.6, 0.8), these equations recover b = 1 and a = 2. The coefficients (2, 1) describe the displacement in this basis; its map coordinates are (2.6, 0.8).

The coordinate frames lesson adds an origin and orthonormal axes, then converts a fixed landmark between world and robot coordinates.

This is a displacement model. A real robot's wheel geometry, obstacles, and motion limits determine which paths it can execute.

Keep points and robot states distinct

A position point tells you where something is. A displacement vector tells you how to move from one point to another. They can share the same coordinate notation while supporting different geometric operations.

  • Subtract two position points to obtain a displacement.
  • Add a displacement to a position to obtain a new position.
  • Choose an origin to represent each position by a position vector from that origin.

Computer Graphics from Scratch illustrates these point and vector operations.

Without a chosen origin, adding two points has no intrinsic meaning. This distinction is part of affine geometry. It prevents a coordinate convention from turning into an unintended physical claim.

For example, start at the map position p = (4, 2) m. Adding our displacement gives p + r = (6.6, 2.8) m. Move the map origin, and their position coordinates change while their difference stays (2.6, 0.8), provided the axes stay fixed.

Vector-space operations also leave lengths and angles unspecified. The dot product supplies that extra geometry for the ordinary vectors used here.

Vector norms give several ways to measure size. That lesson uses (3, 4) to compare the measures and shows how normalization preserves a nonzero vector's direction.

Check the calculation in Python

This example needs no packages. It combines the displacements, then applies the result to a position.

u = (1.0, 0.0)
v = (0.6, 0.8)
a, b = 2.0, 1.0
start = (4.0, 2.0)

displacement = tuple(a * x + b * y for x, y in zip(u, v))
finish = tuple(p + d for p, d in zip(start, displacement))

print(f"displacement: ({displacement[0]:.1f}, {displacement[1]:.1f})")
print(f"finish: ({finish[0]:.1f}, {finish[1]:.1f})")

Expected output:

displacement: (2.6, 0.8)
finish: (6.6, 2.8)

Try it yourself

Exercise 1. Let u = (1, 1) and v = (2, 2). Calculate 2u − v. Can any combination of u and v reach (1, 0)? Explain why.

Show solution: a dependent pair

2u − v = (2, 2) − (2, 2) = (0, 0). Nonzero coefficients produced zero, so the pair is dependent.

Every combination has the form (a + 2b, a + 2b). Its coordinates are equal. The target (1, 0) has unequal coordinates and lies outside the span.

Exercise 2. Which is a subspace of R²: the line y = 0 or the line y = 1? Check zero, addition, and scaling.

Show solution: test the allowed operations

The line y = 0 contains (0, 0). Adding (x, 0) and (z, 0) gives (x + z, 0), and scaling gives (cx, 0). Both results stay on the line, so it is a subspace.

The line y = 1 excludes (0, 0). Adding (0, 1) to itself gives (0, 2), and multiplying by zero gives (0, 0). Those results leave the line, so it is not a subspace.

Continue with linear regression to see a model build its predictions from linear combinations of feature vectors.

Sources and further study