📘 CodingMarble Learn

Linear Algebra: Vector Spaces and Linear Maps

A vector space is a set of arrows you can add and stretch. A linear combination a·u + b·w builds new vectors; the span is everything you can reach. A basis is the smallest set that reaches everything, and its size is the dimension. A matrix is a linear map: its columns say where the basis arrows land.

🎬 Step-by-step story

  1. A vector is an arrow. It has a direction and a length. Here is the red arrow u.
  2. Multiply u by a number a. The arrow gets longer, shorter, or flips. All the results lie on one straight line. That line is the span of u.
  3. Add a blue arrow w that points a different way. Now a·u + b·w can land on every point of the flat plane. The span is the whole plane.
  4. Turn w until it points along u. It adds nothing new. The points fall back onto a line. We say u and w are dependent.
  5. Use the arrows i (right) and j (up). Every point has exactly one pair (a, b). These two arrows are a basis. Two arrows are needed, so the dimension is 2.
  6. Now apply a matrix M. The basis arrows move to new places and the whole grid bends with them. That is a linear map. Drag the sliders and watch.

Tip: drag the 3D scene to turn it. Use two fingers to zoom.

🤔 Common doubts, cleared

Why is a line through the origin a vector space but a shifted line is not?

If you scale a vector by 0 you get the zero vector. A shifted line does not contain it, so the line is not closed under scaling.

Can I reach points off the line using only u?

No. Every a·u lies on the same line through the origin, however big or negative a is.

Why do two arrows reach the whole plane?

Choose a to move along u and b to move along w. Two different directions let you solve for the exact a and b that land on any point.

Why does a dependent pair waste effort?

When w points along u, a·u + b·w is just a multiple of u. The dots fall back on a line, so w added no new direction.

Is the basis unique?

No. Many pairs of independent arrows work. What stays the same is the number of arrows: the dimension.

How does one matrix move every point if it only says where i and j go?

Every point is a·i + b·j. A linear map keeps sums and scalings, so the point goes to a·(image of i) + b·(image of j).

Vectors and vector spaces

A vector is a quantity with a direction and a length. We draw it as an arrow and write it as numbers, such as (2, 1). Two things can always be done to vectors: add them (put the arrows tip to tail) and scale them (stretch or shrink by a number).

A vector space is a collection of vectors where adding two of them, or scaling one, always gives another vector that is still in the collection. The flat plane, with all arrows from the origin, is a vector space. So is ordinary 3D space. The zero vector must be inside every vector space.

A plane that does not pass through the origin is not a vector space: scale a vector by 0 and you leave it.

Linear combinations and span

A linear combination of u and w is any vector a·u + b·w, where a and b are numbers. In the 3D, the green arrow is exactly this: first go a steps along u, then b steps along w.

The span of some vectors is the set of all their linear combinations. One non-zero vector spans a line. Two vectors that point in different directions span a plane. Three vectors that do not lie in a common plane span all of 3D space.

Linear independence, basis and dimension

Vectors are linearly independent if none of them can be built from the others. If w = 2u, then w adds nothing, so they are dependent. Dependent vectors waste effort: the span does not grow.

A basis is a set of independent vectors that span the whole space. With a basis, every vector has exactly one set of coordinates. The usual basis of the plane is i = (1, 0) and j = (0, 1), but many other pairs also work.

The number of vectors in a basis is the dimension. A line has dimension 1, the plane 2, our room 3. Any basis of the same space has the same size.

Matrices as linear maps

A linear map sends vectors to vectors and keeps both rules: it sends u + w to (image of u) + (image of w), and it sends a·u to a·(image of u). Straight lines stay straight, the origin stays fixed, and the grid stays evenly spaced (it may tilt or stretch).

A matrix describes a linear map. Its columns are the places where i and j land. For M with columns (1, 0.3) and (0.8, 1), the arrow i goes to (1, 0.3) and j goes to (0.8, 1). Because the map is linear, the point (a, b) goes to a·(1, 0.3) + b·(0.8, 1). Nothing else needs to be remembered.

The determinant tells how the area of the unit square changes. If it is 0, the map squashes the plane onto a line and the span drops: a dimension is lost. Read more about the two-by-two case in Matrices as functions.

Key formulas and definitions

Worked examples

1. Let u = (1, 2) and w = (3, 0). Find 2u + w.

2u = (2, 4). Add w: (2 + 3, 4 + 0) = (5, 4).

2. Write (7, 2) as a·(1, 0) + b·(0, 1).

(7, 2) = 7·(1, 0) + 2·(0, 1), so a = 7 and b = 2.

3. Are (1, 2) and (3, 6) independent? What is their span?

(3, 6) = 3·(1, 2), so one is a multiple of the other. They are dependent. Their span is only the line through (1, 2), dimension 1.

4. Are (2, 1) and (1, 3) a basis of the plane?

Check the determinant: 2×3 − 1×1 = 5, which is not 0. So the arrows are independent. Two independent vectors in the plane span it, so they are a basis.

5. The matrix M has columns (2, 0) and (0, 3). Where does (1, 1) go?

M(1, 1) = 1·(2, 0) + 1·(0, 3) = (2, 3). The map stretches x by 2 and y by 3.

6. A map has columns (1, 2) and (2, 4). What does it do to the whole plane?

The determinant is 1×4 − 2×2 = 0. The second column is 2 times the first, so every image lies on the line through (1, 2). The plane is squashed onto a line: the output has dimension 1.

Common mistakes

Practice quiz

1. The span of one non-zero vector in the plane is:
2. How many vectors are in a basis of the plane?
3. Which pair is linearly dependent?
4. In a matrix, the first column tells us:
5. A linear map with determinant 0 on the plane:

Practice: answer these yourself

Type or choose your answer, then press Check. Use a hint if you are stuck; the full solution appears after you answer.

Frequently asked questions

What is linear algebra used for?

It is the language of graphics, machine learning, physics and engineering. Anything that mixes quantities in fixed amounts, or rotates, scales and projects shapes, uses it.

What is the difference between span and basis?

The span is every vector you can reach with some arrows. A basis is the smallest, independent set of arrows whose span is the whole space.

Is a matrix the same as a linear map?

Once you fix a basis, yes. The matrix lists where the basis arrows land, and that is enough to know what the map does to every vector.

Learn first

Learn next

Related lessons

All Maths lessons