๐Ÿ”€ Basis and Change of Basis

By Better Wise

Up to now we have measured every vector against the same invisible ruler: the x axis and the y axis. Last lesson we asked when a matrix can be undone, and we tied that answer to rank and span. Now we turn the question around: is the ruler itself a choice? It is. A basis is a chosen set of measuring directions, and switching from one set to another is nothing more than a matrix, specifically the inverse idea you just met.

By the end of this lesson you should be able to:

  • Say what makes a set of vectors a basis, and check it with rank.
  • Read the columns of a change of basis matrix and see what they mean geometrically.
  • Convert coordinates from the standard basis to a new basis and back again.
  • Do both directions in NumPy with a few lines of code.

Coordinates describe an arrow, they are not the arrow

Draw the arrow from the origin to the point $(3, 1)$. The arrow is a real geometric object. When we write $v = (3, 1)$, we are giving an instruction: walk 3 units along the x axis, then 1 unit along the y axis. Those two axis directions are the standard basis:

$$ e_1 = \begin{bmatrix} 1 \ 0 \end{bmatrix}, \qquad e_2 = \begin{bmatrix} 0 \ 1 \end{bmatrix} $$

Nothing is special about them except that they are convenient. We could instead describe the same arrow by walking along a tilted pair of directions. The arrow does not move when you change basis; only the numbers you use to describe it change.

A set of vectors is a basis of the space when it satisfies two conditions:

  1. The vectors are linearly independent: no vector in the set is a redundant combination of the others.
  2. They span the space: every vector in the space can be built from them.

In $\mathbb{R}^n$ this means you need exactly $n$ independent vectors, so the matrix with those vectors as columns is square and invertible, with rank $n$. A dependent set (like $(1,1)$ and $(2,2)$) fails condition 1. Too few vectors (like a single vector in 2D) fails condition 2.

A set of vectors is a basis when it is linearly _____ and _____.

The change of basis matrix: columns, always columns

Given a new basis $b_1, b_2$, pack them as columns of a matrix $B$:

$$ B = \begin{bmatrix} \vert & \vert \ b_1 & b_2 \ \vert & \vert \end{bmatrix} $$

Each column is the new basis vector, written in standard coordinates. That single fact explains the whole mechanism. If $c = (c_1, c_2)$ are the coordinates in the new basis, then

$$ v = B c = c_1 b_1 + c_2 b_2 $$

which is exactly the instruction "take $c_1$ steps along $b_1$ and $c_2$ steps along $b_2$". So $B$ converts new coordinates into standard coordinates.

Take $b_1 = (1,1)$ and $b_2 = (-1,1)$. Picture them: $b_1$ points up and to the right at 45 degrees, $b_2$ points up and to the left. Together they open a V shape that covers the whole plane, so they form a basis.

Now take $v = (3,1)$ in standard coordinates. How many steps along each tilted direction do we need? We want $c_1(1,1) + c_2(-1,1) = (3,1)$, which gives two equations:

$$ c_1 - c_2 = 3, \qquad c_1 + c_2 = 1 $$

Solving: $c_1 = 2$ and $c_2 = -1$. Check: $2(1,1) + (-1)(-1,1) = (2,2) + (1,-1) = (3,1)$. The negative coordinate simply means we step backwards along $b_2$.

Note: If you expect a coordinate like $1.5$, that is fine. Basis coordinates are not required to be whole numbers or positive. They only have to reproduce the arrow.

Practice 1. Using $b_1 = (1,2)$ and $b_2 = (2,1)$, find the coordinates of $v = (3,3)$.

Click to reveal the answer

Solve $c_1(1,2) + c_2(2,1) = (3,3)$: the equations are $c_1 + 2c_2 = 3$ and $2c_1 + c_2 = 3$. Subtract to get $c_2 = c_1$, then $3c_1 = 3$, so $c = (1,1)$. Check: $(1,2) + (2,1) = (3,3)$.

Practice 2. Is the set $(1,1)$ and $(2,2)$ a basis of $\mathbb{R}^2$? Why or why not?

Click to reveal the answer

No. The second vector is twice the first, so they are dependent, rank is 1, and the determinant of the matrix with those columns is $1 \cdot 2 - 2 \cdot 1 = 0$. They span only a line, not the plane.

Walking the other direction: from standard to new coordinates

The forward direction was $v = Bc$. To go backwards, from a known $v$ to the coordinates $c$, we need the inverse:

$$ c = B^{-1} v $$

For our example, $B = [[1, -1], [1, 1]]$ has determinant $1 \cdot 1 - (-1) \cdot 1 = 2$, so

$$ B^{-1} = \frac{1}{2}\begin{bmatrix} 1 & 1 \ -1 & 1 \end{bmatrix} $$

Applying it to $v = (3,1)$: $c_1 = (3 + 1)/2 = 2$ and $c_2 = (-3 + 1)/2 = -1$. We recover $(2, -1)$, as expected. This is why an invertible matrix was the whole point of the previous lesson: only an invertible $B$ lets you translate descriptions in both directions without losing information.

flowchart TD
  Std["๐ŸŽฏ<br/>v: standard coords"]
  New["๐Ÿงญ<br/>c: basis-B coords"]
  Std -->|"solve B c = v"| New
  New -->|"B @ c"| Std

Practice 3. With the same $B$, find the coordinates of $(0, 2)$ in the basis $b_1 = (1,1)$, $b_2 = (-1,1)$.

Click to reveal the answer

$c_1 = (0 + 2)/2 = 1$ and $c_2 = (-0 + 2)/2 = 1$, so $c = (1,1)$. Check: $(1,1) + (-1,1) = (0,2)$.

Doing it in NumPy

Never type the inverse by hand. Build $B$ with its columns, then let np.linalg.solve do the work. It is faster and numerically safer than forming an inverse.

import numpy as np

b1 = np.array([1.0, 1.0])
b2 = np.array([-1.0, 1.0])
B = np.column_stack([b1, b2])          # columns are the new basis vectors

v = np.array([3.0, 1.0])
c = np.linalg.solve(B, v)              # standard coords -> new coords
print(c)                               # [ 2. -1.]
print(B @ c)                           # [3. 1.]  back to standard

np.linalg.det(B)                       # 2.0, nonzero, so B is invertible

To move between two non-standard bases, for example from basis $C$ coordinates to basis $B$ coordinates, convert to standard first and then into the target basis: $c_B = B^{-1} C , c_C$.

Practice 4. Run the snippet, then change v to [0.0, 2.0] and confirm you get [1. 1.]. Then set b2 = b1 and observe what np.linalg.det(B) reports.

Click to reveal the answer

With b2 = b1 the columns are identical, so det(B) is 0.0. The matrix is not invertible, np.linalg.solve raises a LinAlgError, and the set is not a basis.

Habits that keep basis work clean

  • Columns, not rows. The single most common error is stacking basis vectors as rows. If your answers look transposed, this is almost always why.
  • Check with one multiplication. After computing $c$, run B @ c. If it does not return $v$, the coordinates are wrong, full stop.
  • Determinant as a quick filter. A determinant of zero (or very close to it) means the columns are dependent and you do not have a basis.
  • Prefer solve over inv. Same answer, better numerics.
  • Always name the basis when you quote coordinates. "The point is $(3,1)$" is shorthand for "in the standard basis", and it stops being true the moment you change rulers.

What to carry forward

A basis is a choice of measuring directions. Pack those directions as the columns of $B$, then $B$ turns new coordinates into standard ones and $B^{-1}$ turns standard coordinates back into new ones. Everything depends on $B$ being invertible, which is exactly the rank and span idea from the previous lesson, now with a geometric job to do.

Next comes the checkpoint for this module, where you will compose transformations, test invertibility, and switch coordinates in a single problem.

Front: What is a basis of a vector space? Back: A set of linearly independent vectors that spans the whole space.

Front: What does B @ c produce when the columns of B are basis vectors? Back: The standard coordinates of the vector whose basis-B coordinates are c.

Front: Where do the new basis vectors go inside the change of basis matrix? Back: In the columns, each written in standard coordinates.

Front: How do you convert standard coordinates v into basis-B coordinates? Back: Compute B^-1 v, or solve B c = v for c.

Front: Why must a change of basis matrix be invertible? Back: Its columns are independent, so its rank is n and no information is lost.

Front: Does a vector arrow move when you change basis? Back: No, only the numbers used to describe it change.

Front: What is the standard basis of R^2? Back: (1, 0) and (0, 1).

Front: For b1 = (1,1) and b2 = (-1,1), what are the coordinates of (3,1)? Back: (2, -1), since 2b1 - 1b2 = (3,1).

Front: What is the inverse of B = [[1, -1], [1, 1]]? Back: 0.5 * [[1, 1], [-1, 1]].

Front: Which NumPy call converts standard coordinates to new-basis coordinates? Back: np.linalg.solve(B, v).

Front: How do you go from basis-C coordinates to basis-B coordinates? Back: Multiply by B^-1 C, converting to standard first and then into basis B.

Front: What does a determinant of zero tell you about a candidate basis? Back: The vectors are dependent, the rank is too low, so they are not a basis.

To convert standard coordinates to basis-B coordinates, apply _____. In NumPy the safer equivalent is _____.

Practical tips and traps when switching bases

  • Columns, always columns. The single most common mistake is writing the new basis vectors as rows. If the matrix is wrong, every coordinate you compute afterwards is wrong too.
  • Check invertibility before you commit. Run np.linalg.det(B) or np.linalg.matrix_rank(B). A determinant of zero (or a rank below $n$) means the candidate vectors are dependent, so they span less than the whole space and cannot form a basis.
  • Prefer solve over inv. Solving B @ c = v is numerically safer and cheaper than forming B_inv @ v. Use np.linalg.inv when you genuinely need the matrix itself, for example to build the two-way converter.
  • Sanity-check by reconstructing. After finding coordinates c, compute B @ c and confirm you recover the original vector v. This one step catches almost every sign error.
  • Remember what does not change. Lengths, angles, and dot products between vectors are properties of the arrows, not of the coordinates. Only the numbers you write down change.
  • Round-trip test. Converting basis B to standard and back should return your starting coordinates. If it does not, your inverse is built from the wrong vectors.

A useful rule of thumb: a basis is a chosen pair of "rulers" for the space, and a change of basis matrix is just the translation table between two sets of rulers. Geometrically you are rotating your viewpoint, not moving the objects.

What to carry into the checkpoint

You now have the full vocabulary for the end of this module:

  1. A basis is a set of independent vectors that spans the space, so every vector has exactly one coordinate description in it.
  2. The change of basis matrix collects the new basis vectors as columns, expressed in standard coordinates.
  3. Going from standard to new coordinates means applying $B^{-1}$; going back means applying $B$.
  4. Going from one non-standard basis to another means chaining: convert to standard, then convert outward.
  5. Because the columns are independent, every change of basis matrix is invertible and the conversion works in both directions.

Flashcards and cloze items above cover _____ as the main gotcha, so review those first if anything still feels shaky.

Next up is the module checkpoint, where you will combine transformations, rank, and change of basis in short NumPy exercises that mix all three ideas rather than testing them one at a time. Bring a scratchpad: sketching the two grids side by side is still the fastest way to catch a flipped matrix.

SELF_FLAGS: []