Scientia sine finibus

Linear Algebra / Unit 4, Vector Spaces / Topic 4.6

Units and Topics

Unit 4. Vector Spaces

4.6 Change of Basis

This topic shows how the coordinates of a vector change when the basis changes, and how the matrix of a linear map changes with them. A good choice of basis can turn a complicated matrix into a simple one.

You need Topics 3.2, 3.5, 4.3, and 4.5 for this topic.

1. One Vector, Two Descriptions

From Topic 4.3, the coordinates of a vector depend on the basis. In this topic, a list of numbers such as (3, 1) means coordinates in the standard basis unless the text says otherwise.

Take a basis b₁, b₂ of ℝ², and write the basis vectors as the columns of a matrix P. This matrix is called the change of basis matrix. If a vector x has the coordinates c = (c₁, c₂) in the new basis, then x = c₁b₁ + c₂b₂, which is the product Pc.

x = Pc and c = P⁻¹x
  • P changes coordinates in the new basis into standard coordinates.
  • P⁻¹ changes standard coordinates into coordinates in the new basis.

The matrix P has an inverse, because its columns are independent.

For the basis (1, 1), (1, −1) of Topic 4.3,

P = 111−1 P⁻¹ = 1/21/21/2−1/2 P⁻¹ 31 = 21

The vector (3, 1) has the coordinates (2, 1) in this basis, as Topic 4.3 found by solving two equations.

2. From One Basis to Another

Suppose that there are two bases, with the change of basis matrices P and Q. The same vector has the coordinates c in the first basis and d in the second basis. Both describe the same x.

x = Pc = Qd so d = Q⁻¹Pc

Read the product from right to left: P changes the first coordinates into standard coordinates, and Q⁻¹ changes standard coordinates into the second coordinates.

For example, let the first basis be (1, 1), (1, −1) and the second basis be (1, 0), (1, 1). A vector has the coordinates c = (3, 1) in the first basis.

Q = 1101the second basis, as columnsQ⁻¹ = 1−101the inverse of QQ⁻¹P = 021−1the matrix that changes the coordinatesd = 021−1 31 = 22the coordinates in the second basis

Check:

3(1, 1) + 1(1, −1) = (4, 2)the first description2(1, 0) + 2(1, 1) = (4, 2)the second description

3. The Matrix of a Map in a New Basis

Let A be the matrix of a linear map of ℝⁿ in the standard basis, so that the map takes x to y = Ax. In a new basis, the input has the coordinates c and the output has the coordinates d, with x = Pc and y = Pd. Then Pd = APc, and

d = P⁻¹APc

The matrix of the same map in the new basis is B = P⁻¹AP. Read it from right to left: P changes the new coordinates into standard coordinates, A applies the map, and P⁻¹ changes the result back into the new coordinates.

For example, take the map with the matrix A below and the basis (1, 1), (1, −1).

A = 2112the matrix in the standard basisAP = 313−1A times the basis vectorsB = P⁻¹AP = 3001the matrix in the new basis

In the new basis the matrix is diagonal, and the map is easy to describe. It stretches each vector along (1, 1) by the factor 3, and it leaves each vector along (1, −1) unchanged. The standard matrix A describes the same map, but this description is not easy to read from A.

Try it: find a basis that makes the matrix diagonal

Choose a map. Drag the tips of the blue and red arrows to choose a basis. The dashed arrows show where the map sends the two basis vectors. The readout shows the matrix of the map in your basis. Try to find a basis in which the matrix is diagonal.

The matrix is diagonal when the map sends each basis vector to a multiple of itself. In the drawing, each dashed arrow is then on the same line as its basis vector. Vectors with this property are called eigenvectors of the map, and Unit 5 shows how to find them without trial and error. The rotation has no such vectors in the plane, so no basis of real vectors makes its matrix diagonal.

4. Similar Matrices

Two square matrices A and B are called similar when B = P⁻¹AP for some matrix P that has an inverse. Similar matrices are the matrices of one map in two different bases. They share the properties that belong to the map.

PropertyReason
The same determinantdet(P⁻¹AP) = det(P⁻¹) det(A) det(P) = det A
The same traceThe cyclic property of Topic 3.5
The same rankThe dimension of the range does not depend on the basis

For the example, A and B both have the determinant 3 and the trace 4.

5. Rotating the Axes

In physics, the most common change of basis is a rotation of the coordinate axes. The new basis vectors are the standard unit vectors turned by an angle θ, so P is the rotation matrix of Topic 3.1. Its inverse is the rotation by −θ, which is also its transpose.

P = cos θ−sin θsin θcos θ P⁻¹ = PT = cos θsin θ−sin θcos θ

A vector with the components (x, y) on the original axes has these components on the rotated axes:

x′ = x cos θ + y sin θ y′ = −x sin θ + y cos θ

You have used this in problems with an inclined plane, where the weight is split into a component along the incline and a component perpendicular to it. The weight is the same vector in both descriptions. The length of a vector does not change when the axes are rotated.

A change of basis whose matrix satisfies P⁻¹ = PT keeps all lengths and angles. Unit 6 studies these matrices. In quantum mechanics, the state of a particle can be described in a basis of positions or in a basis of momenta, and the change between these two descriptions is a change of basis of this kind.

Common Mistakes

  • Using P when P⁻¹ is needed. P takes new coordinates to standard coordinates. To find the new coordinates of a known vector, use P⁻¹.
  • Writing the basis vectors as the rows of P. They are the columns.
  • Calculating the new matrix as PAP⁻¹. With the basis vectors in the columns of P, the matrix in the new basis is P⁻¹AP.
  • Thinking that a change of basis changes the map. The map is the same. Only its matrix changes.
  • Expecting A and P⁻¹AP to have the same entries. They share the determinant, the trace, and the rank, but the entries are usually different.

Summary

FactStatement
Change of basis matrixP has the new basis vectors as its columns
Coordinatesx = Pc and c = P⁻¹x
Between two basesd = Q⁻¹Pc
Matrix of a map in the new basisB = P⁻¹AP
Similar matricesThey have the same determinant, trace, and rank
Rotated axesP is a rotation matrix, and P⁻¹ = PT

Practice

Work each problem on paper first. Then open the answer to check your work.

1. Find the coordinates of (5, 3) in the basis (2, 1), (1, 1).

P = 2111 has the determinant 1, so P⁻¹ = 1−1−12.

c = P⁻¹(5, 3)the coordinates in the new basisc = (5 − 3, −5 + 6) = (2, 1)2(2, 1) + 1(1, 1) = (5, 3)the check

2. A vector has the coordinates (3, −2) in the basis (1, 1), (1, −1). Find its standard coordinates.

x = Pcthe vector from its coordinatesx = 3(1, 1) − 2(1, −1) = (1, 5)

3. Find the matrix of the map A = 1203 in the basis (1, 0), (1, 1).

P = 1101 and P⁻¹ = 1−101.

AP = 1303, and P⁻¹AP = 1003.

The matrix is diagonal in this basis.

4. A has the determinant 6 and the trace 5, and B = P⁻¹AP. Find the determinant and the trace of B.

Similar matrices have the same determinant and the same trace, so det B = 6 and tr B = 5.

5. The axes are rotated by 30°. Find the components of the vector (2, 0) on the rotated axes.

x′ = 2 cos 30° + 0 = √3 ≈ 1.73y′ = −2 sin 30° + 0 = −1x′² + y′² = 3 + 1 = 4the length is still 2

6. The same vector has the coordinates c = (1, 1) in the basis (1, 1), (1, −1). Find its coordinates in the basis (1, 0), (1, 1).

From Part 2, d = Q⁻¹Pc with Q⁻¹P = 021−1.

d = (0 + 2, 1 − 1) = (2, 0)

Check: both descriptions give the vector (2, 0).

Python Practice

Step 1. Change to a new basis

The instruction np.column_stack builds the change of basis matrix P from the basis vectors. The instruction np.linalg.inv calculates an inverse, and the @ sign multiplies matrices and vectors. The code below finds the coordinates of (3, 1) in the basis (1, 1), (1, −1).

Python

The result is [2. 1.], as in Part 1.

In the next box, the coordinates are given and the vector is wanted. Change the line that starts with x so that x holds the standard coordinates of the vector with the coordinates (3, −2) in this basis. This is Practice Problem 2.

Python

Step 2. Go from one basis to another

From Part 2, coordinates c in a first basis become coordinates d in a second basis through d = Q⁻¹Pc. In the next box, the line that calculates d is not complete: it leaves out the matrix P. Correct that line.

Python

Step 3. Find the matrix of a map in a new basis

The code below calculates B = P⁻¹AP for the example of Part 3.

Python

The result is the diagonal matrix with the entries 3 and 1.

Now change P to the matrix of the basis (1, 0), (1, 1). The basis vectors are the columns of P, and a matrix is typed by its rows.

Python

Step 4. Compare the trace and the determinant

The code below prints the trace and the determinant of A and of B = P⁻¹AP. The instruction round removes very small rounding errors.

Python

The traces are both 4, and the determinants are both 3. Change P to any other matrix that has an inverse and run the code again. The four results do not change.

Step 5. Rotate the axes

The code below finds the components of the vector (2, 0) on axes that are rotated by 30 degrees, as in Practice Problem 5. The instructions np.cos and np.sin need the angle in radians, so np.radians changes degrees to radians. For a rotation, the inverse of P is its transpose, P.T.

Python

The components are about 1.73 and −1. The second result is the length of the vector, which is still 2.

Now rotate the axes by 90 degrees. Before you press Run, decide what the components should be from a sketch.

Python

Quiz

This quiz has 5 questions on this topic. A question asks you either to choose one answer or to type numbers. The page grades your answers and explains each one. A number can be typed as a whole number, a decimal, a fraction such as 1/3, or a calculation such as sqrt(18)/2 or arccos(1/2). The page shows the value of a calculation next to the box. Angles in a calculation are in degrees. The Calculator button under each question opens a calculator. Your answers are saved in your browser, so they are still on the page when you come back to it.

Choose how your answers are checked

1. A vector has the coordinates (2, 3) in the basis (1, 1), (1, −1). Find its standard coordinates.

2. Find the coordinates of the vector (6, 2) in the basis (1, 1), (1, −1).

3. A map has the matrix A in the standard basis. The columns of P are the vectors of a new basis. Which matrix is the matrix of the map in the new basis?

4. Which properties are always the same for two similar matrices?

5. Let A = 3102. Calculate A times the vector (1, −1).

Next: Topic 5.1, Eigenvalues and Eigenvectors