A basis is a set of vectors that reaches everything and has nothing spare. Prove that it gives every vector exactly one list of coordinates, meet the standard basis, and learn what dimension really counts: the number of vectors in any basis, not the number of entries.
State the definition of a basis as a linearly independent set that spans, and decide whether a small set of vectors is one.
Prove that every vector has exactly one list of coordinates in a given basis.
Find the coordinates of a vector in a basis of the plane, and read ordinary coordinates as weights on the standard basis.
State what dimension counts, and give the dimension of a line, a plane through the origin and the whole of n-dimensional space.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
A point of the plane takes two numbers to describe, and a point of space takes three. Is that a fact about the plane and about space, or only about how we chose to write vectors down? Could a clever set of building blocks describe the plane with one number, or need three? Machine learning asks the same about data: how many numbers does it really take to describe this?
From the last lesson
1. What does it mean for vectors \(\vect{v}_1, \dots, \vect{v}_k\) to be linearly independent?
Show answer
The only weights with \(c_1\vect{v}_1 + \cdots + c_k\vect{v}_k = \vect{0}\) are \(c_1 = \cdots = c_k = 0\).
2. How many vectors in the plane can be linearly independent at most?
Show answer
Two. Any three vectors in the plane are dependent.
Intuition
Choose some vectors as building blocks for the plane and set them two tests. Can they reach every point? Then they span the plane (lesson M02.2.2). Is none of them spare? Then they are independent (lesson M02.2.3). A set that passes both tests is a basis: enough vectors, and not one too many.
M02.2.4-F1
Three sets of building blocks, each asked for the point \((2, 1)\). One vector cannot reach it. Three reach it in more than one way. Two independent vectors reach it in exactly one way.
Here \(\vect{u} = (1, -1)\), \(\vect{v} = (1, 2)\) and \(\vect{w} = (3, 0)\).
Build it up
Step 1. Too few: some points have no recipe. The vector \(\vect{u}\) alone spans a line. The point \((2, 1)\) is not on it.
Step 2. Too many: some points have several recipes. With \(\vect{u}\), \(\vect{v}\) and \(\vect{w}\) every point is reached, but not in one way only:
Step 3. Two recipes make a round trip. Go out by the first recipe and come back by the second, reversed. You are home again, having walked a combination with weights \(1 - (-1) = 2\), \(1 - 0 = 1\) and \(0 - 1 = -1\):
That is the round trip of the last lesson. Two recipes for one point need a dependent set.
M02.2.4-F2
Two different recipes for the same point, subtracted, are a round trip with weights that are not all zero. An independent set has no such round trip.
Step 4. Just right: one recipe, and its weights are coordinates. With \(\vect{u}\) and \(\vect{v}\) alone every point is reached (they span the plane) and no round trip exists (they are independent). So every point has exactly one pair of weights: its coordinates in the basis \(\vect{u}, \vect{v}\), its address on the slanted grid.
Step 5. Counting. Every basis of the plane turns out to have exactly two vectors. That count is the dimension of the plane.
The formal statement
In what follows \(V\) is either all of \(\R^n\) or a span inside it, such as a line or a plane through the origin.
NoteDefinition: basis
A basis of \(V\) is a set of vectors \(\vect{v}_1, \dots, \vect{v}_k\) in \(V\) that
is linearly independent, and
spans \(V\).
NoteTheorem: coordinates are unique
If \(\vect{v}_1, \dots, \vect{v}_k\) is a basis of \(V\), then every vector \(\vect{x}\) in \(V\) can be written as
The basis is independent, so the only weights that give \(\vect{0}\) are all zero. Hence \(a_i - b_i = 0\), that is \(a_i = b_i\), for every \(i\). The two ways were the same way. \(\blacksquare\)
The standard basis. In \(\R^n\) let \(\vect{e}_i\) be the vector with a 1 in entry \(i\) and zeros elsewhere. In the plane these are \(\ihat = (1, 0)\) and \(\jhat = (0, 1)\). For any weights,
This one line shows two things. The set spans \(\R^n\): to reach \(\vect{x} = (x_1, \dots, x_n)\), take \(c_i = x_i\). And it is independent: the combination equals \(\vect{0}\) only when \((c_1, \dots, c_n) = (0, \dots, 0)\). So \(\vect{e}_1, \dots, \vect{e}_n\) is a basis, the standard basis, and the coordinates of \(\vect{x}\) in it are simply its entries. The numbers we have written all along were coordinates in this basis.
A test in the plane. Two vectors \(\vect{u}, \vect{v}\) form a basis of the plane exactly when \(D = u_1 v_2 - u_2 v_1 \neq 0\): that condition makes them span the plane (lesson M02.2.2) and makes them independent (lesson M02.2.3). The coordinates of a point are then given by the formula of lesson M02.2.1.
NoteTheorem and definition: dimension
Any two bases of \(V\) contain the same number of vectors. That number is the dimension of \(V\), written \(\dim V\).
Proof for the plane. A basis of the plane cannot have one vector, because one vector spans at most a line (lesson M02.2.2). It cannot have three or more, because any three vectors in the plane are dependent (lesson M02.2.3), and their round trip extends to the whole set by giving the rest the weight zero. So every basis of the plane has exactly two vectors, and \(\dim \R^2 = 2\). The general proof is in the block below.
\(\dim \R^n = n\), counted on the standard basis.
A line through the origin has dimension 1: any non-zero vector on it is a basis.
A plane through the origin has dimension 2, wherever it sits. The sheet spanned by \((1, 0, 1)\) and \((0, 1, 1)\) lives in \(\R^3\) and has dimension 2.
Go deeper: why every basis has the same number of vectors
The key fact: if \(\vect{w}_1, \dots, \vect{w}_m\) are independent and all lie in \(S = \operatorname{span}\{\vect{v}_1, \dots, \vect{v}_n\}\), then \(m \le n\). The proof swaps the \(\vect{v}\)’s for \(\vect{w}\)’s one at a time, keeping the span equal to \(S\) throughout.
One swap. Suppose the vectors \(\vect{w}_1, \dots, \vect{w}_{j-1}\) together with some remaining \(\vect{v}\)’s span \(S\). Since \(\vect{w}_j\) is in \(S\), it is a combination of the earlier \(\vect{w}\)’s, with weights \(a\), and the remaining \(\vect{v}\)’s, with weights \(b\):
The \(b\)’s cannot all be zero. If they were, \(\vect{w}_j\) would be a combination of the earlier \(\vect{w}\)’s (or, when \(j = 1\), would be \(\vect{0}\)), and the \(\vect{w}\)’s would be dependent. Say \(b_1 \neq 0\). Divide by it to write \(\vect{v}_{i_1}\) as a combination of \(\vect{w}_1, \dots, \vect{w}_j\) and the other remaining \(\vect{v}\)’s. Now use Fact 3 of lesson M02.2.2 twice. Adding \(\vect{w}_j\) to the spanning set does not change the span, because \(\vect{w}_j\) is in it. Removing \(\vect{v}_{i_1}\) then does not change it either, because \(\vect{v}_{i_1}\) is in the span of what is left. One \(\vect{v}\) has been swapped for \(\vect{w}_j\), and the span is still \(S\).
Counting. Each swap uses up one \(\vect{v}\). Suppose \(m > n\). After \(n\) swaps no \(\vect{v}\) is left, so \(\vect{w}_1, \dots, \vect{w}_n\) span \(S\). But \(\vect{w}_{n+1}\) is in \(S\), so it is a combination of the other \(\vect{w}\)’s, which contradicts independence. Hence \(m \le n\).
Bases. Let one basis of \(V\) have \(m\) vectors and another have \(n\). The first is independent and lies in the span of the second, so \(m \le n\). Swapping their roles gives \(n \le m\). So \(m = n\).
The same fact shows that any \(n + 1\) vectors in \(\R^n\) are dependent, since \(\R^n\) is spanned by the \(n\) vectors of the standard basis.
Worked example
Is \(\vect{u} = (1, -1)\), \(\vect{v} = (1, 2)\) a basis of the plane? If so, find the coordinates of \(\vect{p} = (5, 1)\) in it.
M02.2.4-F3
One point, two bases, two lists of coordinates. In the standard basis \(\vect{p}\) is \((5, 1)\). In the basis \(\vect{u}, \vect{v}\) the same point is \((3, 2)\).
Is it a basis?\(D = {1 \cdot 2} - {(-1) \cdot 1} = 3 \neq 0\). So the two vectors are independent and span the plane: yes.
Coordinates. We need \({a\,\vect{u}} + {b\,\vect{v}} = (a + b,\; -a + 2b) = (5, 1)\). Adding \(a + b = 5\) and \(-a + 2b = 1\) gives \(3b = 6\), so \(b = 2\) and \(a = 3\). The coordinates of \(\vect{p}\) in this basis are \((3, 2)\).
Compare. In the standard basis, \(\vect{p} = {5\,\ihat} + {1\,\jhat}\), with coordinates \((5, 1)\). The point has not moved. Only the grid used to describe it has changed, which is the subject of module M02.9.
Three sets that are not bases of the plane.
\((1, 2), (2, 4)\): \(D = {1 \cdot 4} - {2 \cdot 2} = 0\). Dependent, and they span only a line.
\((1, 0), (0, 1), (1, 1)\): they span the plane but are dependent, so recipes are not unique:
\((3, 0)\) alone: independent, but it spans only a line.
A basis for the sheet. Let \(V\) be the span of \(\vect{u} = (1, 0, 1)\) and \(\vect{v} = (0, 1, 1)\). They span \(V\) by definition and are independent, since neither is a multiple of the other. So they are a basis of \(V\), and \(\dim V = 2\). The point \((1, 2, 3) = {1\,\vect{u}} + {2\,\vect{v}}\) has coordinates \((1, 2)\) in this basis: two numbers for a point written with three.
Code
From scratch, coordinates in a basis of the plane are the weights of lesson M02.2.1.
def coordinates(basis, p):"""The coordinates of p in a basis (u, v) of the plane.""" u, v = basis D = u[0] * v[1] - u[1] * v[0]if D ==0:raiseValueError("not a basis: the two vectors lie along one line")return (p[0] * v[1] - p[1] * v[0]) / D, (u[0] * p[1] - u[1] * p[0]) / Ddef combine(weights, vectors): total = [0] *len(vectors[0])for c, v inzip(weights, vectors): total = [t + c * x for t, x inzip(total, v)]returntuple(total)p = (5, 1)print("standard basis:", coordinates([(1, 0), (0, 1)], p))print("basis u, v: ", coordinates([(1, -1), (1, 2)], p))spare = [(1, 0), (0, 1), (1, 1)] # spans the plane, but is not a basisprint("two recipes for (2, 3):", combine([2, 3, 0], spare), combine([0, 1, 2], spare))
standard basis: (5.0, 1.0)
basis u, v: (3.0, 2.0)
two recipes for (2, 3): (2, 3) (2, 3)
With NumPy, put the basis vectors side by side as columns. np.linalg.solve finds coordinates, and np.linalg.matrix_rank gives the dimension of a span.
import numpy as npbasis = np.column_stack([(1.0, -1.0), (1.0, 2.0)])print("coordinates of (5, 1):", np.linalg.solve(basis, [5, 1]))print("standard basis of R^3:\n", np.eye(3))u, v = np.array([1.0, 0.0, 1.0]), np.array([0.0, 1.0, 1.0])rng = np.random.default_rng(0)weights = rng.normal(size=(200, 2)) # 200 points of the sheet, by their coordinatesdata = weights @ np.vstack([u, v]) # the same points, written with 3 entries eachprint("shape of the data:", data.shape, " dimension of its span:", np.linalg.matrix_rank(data))
coordinates of (5, 1): [3. 2.]
standard basis of R^3:
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
shape of the data: (200, 3) dimension of its span: 2
The data array has three columns, yet its rows span only two dimensions. Each row can be stored as two coordinates in the basis \(\vect{u}, \vect{v}\) and rebuilt exactly. Finding such a basis for real data is the idea behind principal component analysis, in course M03.
Explore
In the span explorer of lesson M02.2.2, the two vectors you drag are a basis of the plane whenever the whole plane is shaded. Jump to the target then finds the target’s coordinates in your basis. With Standard basis they are its ordinary entries.
Pitfalls
M02.2.4-F4
Wrong beside right. The points of the sheet are written with three entries, but the sheet has dimension 2: on the sheet itself, two coordinates locate any point.
“The vectors have three entries, so the space is three-dimensional.”
Dimension counts the vectors in a basis, not the entries in a vector. The sheet has dimension 2 although its points have three entries. Data with many features is often close to this: many features can be explained by a combination of others (Mathematics for Machine Learning, chapter 10).
“The basis of the plane is \(\ihat\) and \(\jhat\).”
That is a basis, the standard one. Any two vectors with \(D \neq 0\) form another, so the plane has infinitely many bases. What they share is their size: two.
“Basis vectors must be perpendicular and of length one.”
The definition does not ask for that. \(\vect{u} = (1, -1)\) and \(\vect{v} = (1, 2)\) are neither, and they are a good basis. Perpendicular unit vectors are a convenience (module M02.10).
Frontier note: adapting a large model inside a small span
LoRA (Hu and others, 2021) adapts a large pre-trained model without changing its weight matrix \(\mat{W}_0\). It learns an update of the form \(\mat{B}\mat{A}\), where \(\mat{B}\) has only \(r\) columns and \(r\) is far smaller than the size of the layer. The change in the layer’s output for an input \(\vect{x}\) is \(\mat{B}(\mat{A}\vect{x})\), which is a linear combination of the \(r\) columns of \(\mat{B}\) (lesson M02.4.2). So whatever the input, the change lies in the span of \(r\) vectors, a space of dimension at most \(r\). The abstract reports that this can cut the number of trainable parameters by a factor of 10,000 compared with fine-tuning all of GPT-3.
Check yourself
Recall
1. Which two properties make a set of vectors a basis of \(V\)?
Show answer
It is linearly independent, and it spans \(V\).
2. What are the coordinates of a vector in a basis?
Show answer
The weights of the one linear combination of the basis vectors that equals the vector.
3. Why can a vector not have two different lists of coordinates in one basis?
Show answer
Subtracting the two recipes would give a combination equal to \(\vect{0}\) with weights that are not all zero, and an independent set has no such combination.
4. What is the standard basis of \(\R^3\), and what are the coordinates of \((4, -1, 2)\) in it?
Show answer
\(\vect{e}_1 = (1, 0, 0)\), \(\vect{e}_2 = (0, 1, 0)\), \(\vect{e}_3 = (0, 0, 1)\). The coordinates are the entries themselves: \((4, -1, 2)\).
5. What does the dimension of \(V\) count? What is the dimension of a plane through the origin in \(\R^3\)?
Show answer
The number of vectors in any basis of \(V\). A plane through the origin has dimension 2.
Exercises
1.★ Which of these are bases of the plane? (a) \((2, 1), (1, 3)\) (b) \((2, 1), (-4, -2)\) (c) \((1, 0), (0, 1), (2, 1)\) (d) \((3, 0)\).
(b) No: \(D = {2 \cdot (-2)} - {1 \cdot (-4)} = 0\). The second vector is \(-2\) times the first.
(c) No: three vectors in the plane are dependent. Here \((2, 1) = {2\,(1, 0)} + {1\,(0, 1)}\).
(d) No: one vector spans only a line.
2.★★ (a) Find the coordinates of \((7, 11)\) in the basis \((2, 1), (1, 3)\) of the plane. (b) The vectors \((1, 1, 2)\) and \((1, -1, 0)\) both lie on the sheet spanned by \((1, 0, 1)\) and \((0, 1, 1)\). Find the coordinates of \((1, 2, 3)\) with respect to them.
Show solution
(a) Solve \(2a + b = 7\) and \(a + 3b = 11\). From the first, \(b = 7 - 2a\). Then \(a + 3(7 - 2a) = 11\) gives \(-5a = -10\), so \(a = 2\) and \(b = 3\). Check: \({2\,(2, 1)} + {3\,(1, 3)} = (4 + 3,\; 2 + 9) = (7, 11)\). The coordinates are \((2, 3)\).
(b) We need \({a\,(1, 1, 2)} + {b\,(1, -1, 0)} = (a + b,\; a - b,\; 2a) = (1, 2, 3)\). The third entry gives \(a = 1.5\). The first gives \(b = 1 - 1.5 = -0.5\). The second checks: \(1.5 + 0.5 = 2\). The coordinates are \((1.5, -0.5)\).
The new pair is another basis of the sheet: neither vector is a multiple of the other, and the pair reaches the old basis, since \((1, 0, 1) = \tfrac12(1, 1, 2) + \tfrac12(1, -1, 0)\) and \((0, 1, 1) = \tfrac12(1, 1, 2) - \tfrac12(1, -1, 0)\). In the old basis the point had coordinates \((1, 2)\). A different basis, still two vectors.
3.★★★ Let \(\vect{v}_1, \dots, \vect{v}_k\) be a basis of \(V\). Prove that (a) removing any one vector leaves a set that no longer spans \(V\), and (b) adding any further vector of \(V\) makes the set dependent.
Show solution
(a) Remove \(\vect{v}_j\) and suppose the rest still spanned \(V\). Then \(\vect{v}_j\), which is in \(V\), would be a linear combination of the others. By the theorem of lesson M02.2.3 the full set would be dependent, contradicting that it is a basis. So the smaller set does not span \(V\).
(b) Let \(\vect{w}\) be any vector of \(V\). The basis spans \(V\), so \(\vect{w}\) is a linear combination of \(\vect{v}_1, \dots, \vect{v}_k\). By the same theorem, the set \(\vect{v}_1, \dots, \vect{v}_k, \vect{w}\) is dependent.
So a basis is a spanning set with nothing to spare, and an independent set with no room for more.
Summary card
A basis reaches everything, with nothing spare.
M02.2.4-F1
Too few, just right, too many.
Basis of \(V\). A set that is linearly independent and spans \(V\).
Coordinates. Each \(\vect{x}\) in \(V\) is \(c_1\vect{v}_1 + \cdots + c_k\vect{v}_k\) in exactly one way.
Standard basis.\(\vect{e}_1, \dots, \vect{e}_n\); the coordinates of \(\vect{x}\) are its entries.
In the plane.\(\vect{u}, \vect{v}\) is a basis exactly when \(D = u_1 v_2 - u_2 v_1 \neq 0\).
Dimension. The number of vectors in any basis: \(\dim \R^n = n\), a line 1, a plane 2.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Sheldon Axler, Linear Algebra Done Right, 4th edition (open access). Section 2B: definition 2.26 (basis), example 2.27 (the standard basis) and criterion 2.28 (unique representation, proved by subtraction as here). Section 2A, result 2.22: an independent list is never longer than a spanning list, the fact proved in the deeper block. Section 2C: result 2.34 (any two bases have the same length) and definition 2.35 (dimension).
Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra, Section 2.7, Basis and Dimension. The definitions of basis and dimension; a non-zero subspace has infinitely many bases, all with the same number of vectors.
Marc Deisenroth, Aldo Faisal and Cheng Soon Ong, Mathematics for Machine Learning (free PDF). Section 2.6.1: definition 2.14 (basis), and the remark that the dimension of a space is not necessarily the number of entries of its vectors. Chapter 10 opens with the remark on high-dimensional data used in the first pitfall.
Gilbert Strang, Independence, basis and dimension, MIT OpenCourseWare 18.06SC. A lecture with problems and solutions: the number of basis vectors equals the dimension.
Edward Hu and others (2021), LoRA: Low-Rank Adaptation of Large Language Models. Section 4.1 gives the update \(\mat{W}_0 + \mat{B}\mat{A}\) with rank \(r\); the abstract gives the reduction in trainable parameters quoted in the frontier note.
Next. This module is complete. Module M02.3 adds lengths and angles to the picture, and M02.4 Matrices as linear maps shows that a linear map is fixed by what it does to a basis.