Chapter 11: Change of basis

Previous: LA 10 Singular Value Decomposition | LA 00 Course Map | Next: LA 12 Matrix Calculus and Numerical Practice

The big idea

A vector is a geometric object; its coordinates are only a description of it, relative to a chosen set of axes. Change the axes and the numbers change, but the object does not. The same is true of linear maps. Choosing good axes (a good basis) can turn a hard problem into an easy one. Diagonalization, PCA and every coordinate-frame calculation in robotics are applications of this one idea.

In this chapter you will learn to
  1. Find the coordinates of a vector in any basis, and convert back.
  2. Rewrite a linear map in a new basis using .
  3. Explain diagonalization as “choosing the eigenvector basis”.
  4. Convert points and directions between robot coordinate frames, and chain frames.
  5. Write matrices for linear maps on spaces of polynomials and functions.
Before you start

11.1 Coordinates depend on the basis

The same arrow, different numbers

When we write , we secretly mean

“3 steps along the first standard axis and 2 along the second”. The numbers are coordinates relative to the standard basis.

Now pick different axes: and . These form a basis of (two independent vectors). The same arrow can be written as

for some unique numbers . Those are the coordinates of in the basis , written .

Finding the new coordinates

Put the new basis vectors as columns of a matrix . Then

so the equation is just , and

Converting coordinates

Worked example 11.1. , , .

Solve and : adding gives , so , .

So . Check: ✓.

The arrow is the same. Its description changed from to .

A way not to mix up the directions

The two formulas are easy to swap by accident. Test with a basis vector: itself must have new coordinates . And indeed first column of ✓. So takes new coordinates to standard ones.

Orthonormal bases: no inverse needed

If the new basis is orthonormal, is an orthogonal matrix and . Then each new coordinate is a single dot product:

Worked example 11.2. Orthonormal basis , , and :

and . So .


11.2 The same linear map in a new basis

The question

A matrix describes a linear map in standard coordinates: feed it standard coordinates, get standard coordinates out. What matrix describes the same map if we work in -coordinates throughout?

Follow a vector through

Start with a vector given in -coordinates, . To apply the map:

  1. Convert to standard coordinates: .
  2. Apply the map (which we know in standard coordinates): .
  3. Convert the result back to -coordinates: .

So

Change of basis for a map

Read it right to left: into standard coordinates, apply , back out to -coordinates.

Similar matrices

Two matrices related by (for some invertible ) are called similar. They are the same map seen from different viewpoints. So they share every property that belongs to the map rather than to the description:

Shared by similar matricesWhy
eigenvaluessame stretch factors (chapter 8, exercise C5)
determinantsame volume scaling (chapter 7, exercise C2)
tracesum of eigenvalues
ranksame number of independent output directions

What is not shared: the individual entries, and the eigenvectors’ coordinates (they are re-described in the new basis).


11.3 Diagonalization is choosing the right basis

Take the basis of eigenvectors of , so . Then

In the eigenvector basis, the map is diagonal: each coordinate is scaled independently, with no mixing.

That is what diagonalization really means. The matrix was never complicated; it only looked complicated because we were describing it with axes that did not match its natural directions.

Worked example 11.3. with the basis , (its eigenvectors, eigenvalues 3 and 1).

In standard coordinates, the map mixes and . In eigen-coordinates, it is “triple the first coordinate, keep the second”.

Worked example 11.4 (a non-eigen basis, for contrast). Same , but with basis , :

Not diagonal, but it is still the same map: trace ✓, determinant ✓, eigenvalues ✓.


11.4 Coordinate frames in robotics

Frames

A robot uses many coordinate frames: the world frame, the robot base, each link, the camera, the gripper, the object. The same physical point has different coordinates in each.

Writing the frame next to every quantity prevents most bugs. Notation: means “point described in frame ”.

Rotations between frames

A rotation matrix is built so that its columns are the axes of frame , written in frame . Then

This is exactly from section 11.1: frame ‘s axes play the role of the new basis.

Because rotation matrices are orthogonal, going the other way is free:

Chaining frames

To go from frame to frame via frame :

The inner labels cancel, like fractions: . If adjacent labels do not match, the product is a bug.

Worked example 11.5

A camera is mounted rotated counterclockwise relative to the world (in 2-D). The camera sees an object at : two units straight ahead along the camera’s own -axis. Where is it in the world?

The camera’s -axis, written in world coordinates, is ; its -axis is . So

“Straight ahead of the camera” is “north” in the world, because the camera faces north.

Adding translation: homogeneous coordinates

Frames are usually shifted as well as rotated: , where is the position of ‘s origin in . Adding a shift is not linear (chapter 3), but a trick makes it linear: append a 1 to every point and use a (in 3-D) matrix:

Now chaining frames is again matrix multiplication, . This is the language of 02 Geometry and Kinematics.

Points versus directions

Points get the shift; directions (velocities, surface normals) do not. In homogeneous coordinates, append 1 to a point and 0 to a direction: the 0 automatically removes the shift.


11.5 Why change basis at all?

PurposeChosen basisEffect
decouple a dynamical systemeigenvectors becomes separate scalar equations
remove correlationeigenvectors of the covariancevariables become uncorrelated: PCA
compress signalsFourier or wavelet basissmooth signals need few coefficients (JPEG, MP3)
simplify a task descriptiongripper or object frame”move forward 5 cm” is one coordinate
numerical stabilityorthonormal basisno amplification of errors

11.6 Beyond arrows: polynomials and functions

Vectors do not have to be lists of numbers. Anything you can add and scale, with the usual rules, forms a vector space.

Polynomials as vectors

Polynomials of degree at most 2, such as , can be added and scaled, and they form a vector space with basis . The coordinates of in this basis are .

A linear map: differentiation

Differentiation is linear: and . Find its matrix by the chapter 3 recipe: where does each basis vector go?

  • , coordinates .
  • , coordinates .
  • , coordinates .

Write these as columns:

Check. , which is the polynomial . And indeed ✓.

Notice: has a null space (constants differentiate to zero) and is not invertible, matching the fact that you cannot recover the constant term after differentiating. Integration “inverts” it only up to that constant.

The general principle

Once you choose a basis, every linear map between finite-dimensional spaces becomes a matrix. That is why linear algebra applies to signals, images, functions and quantum states, not just to arrows.


Summary

IdeaFormula
new to standard
standard to new
orthonormal basis
map in new basis
similar matricessame eigenvalues, det, trace, rank
diagonalizationeigenvector basis makes diagonal
frames, ,

Three facts to remember:

  1. Coordinates describe a vector; they are not the vector.
  2. : into standard, apply, back out.
  3. Label every frame; adjacent labels must match before you multiply.

Exercises

Part A: warm-up

A1. Find the coordinates of in the basis .

A2. The orthonormal basis , . Find the coordinates of using dot products.

A3. If and , , what are and ?

A4. Write the matrix of differentiation on polynomials of degree at most 3, in the basis .

Part B: core

B1. Let . Using its eigenvectors and as a basis, compute and confirm it is diagonal.

B2. A robot base frame is rotated counterclockwise from the world frame and its origin is at in the world. A point is at in base coordinates. Find its world coordinates.

B3. In the situation of B2, a point is at in the world. Where is it in base coordinates?

B4. The map “reflect across the line ” has matrix . Write it in the basis . Why is the result so simple?

B5. Show that the trace of equals the trace of , using the fact .

Part C: explain and prove

C1. Prove that if , then . Why is this useful?

C2. Explain why the same vector can be an eigenvector of but have different coordinates in different bases, and how its coordinates in the new basis relate to the eigenvectors of .

C3. Explain why, in robotics code, writing R_world_cam @ R_gripper_world is a warning sign.

C4. Is “the set of all polynomials of degree exactly 2” a vector space? Why or why not?

Part D: practise with code

D1. Write to_basis(v, B) using np.linalg.solve(B, v) and from_basis(c, B) using B @ c. Check that they undo each other on random inputs.

D2. Build 2-D homogeneous transforms T(theta, tx, ty) as matrices. Compose three of them and check that applying them one at a time gives the same result as applying the product.

D3. For a random symmetric matrix , compute Q.T @ S @ Q where Q comes from np.linalg.eigh(S). Confirm it is diagonal (up to rounding).


Where this is used

  • Every pose computation in 02 Geometry and Kinematics is a change of basis.
  • Choosing whether a policy outputs actions in the camera, gripper or base frame changes how well it generalizes (12 Human Data and Embodiment).
  • Fourier analysis, PCA and modal analysis of vibrations are all changes to a well-chosen basis.

Next: LA 12 Matrix Calculus and Numerical Practice: derivatives with vectors and matrices, and computing safely.