---
title: Linear transformations and change of basis
heading: The same action, seen from a better angle
eyebrow: A7 · Lesson 48 · Change of basis
xp: 40
---

::: hook
A motor drive measures three phase currents that swing back and forth 60 times a second, yet its control loop regulates two steady numbers. The trick is to describe the currents in a coordinate frame that spins along with the rotor's magnetic field. Seen from that spinning frame, the rotating current vector stands still, and AC becomes DC. That's a **change of basis**: the physics doesn't change, only the coordinates you describe it in. Picking the right basis is how hard problems become easy ones.
:::

::: play
- The current vector turns at $\omega$ = 1 (in units of the line frequency). The curves show its two coordinates in a frame turning at speed $s$.
- At $s = 0$ the frame stands still and you see the AC currents themselves. At $s = 1$ the frame turns with the vector.
- Set $s$ to 1. What do the coordinates do? Now set it a little off 1.
:::
:::

```sim plot
view: graph
x: t = 0..20 s
y: i = -1.2..1.2 A
slider: s = 0..1.5 step 0.05 = 0
slider: ph = 0..90 step 5 = 30 °
plot: cos((1 - s)*t + ph°) | label: d coordinate | samples: 1500
plot: sin((1 - s)*t + ph°) | label: q coordinate | color: ch2 | samples: 1500
readout: d in the locked frame = cos(ph°) | digits: 3
readout: q in the locked frame = sin(ph°) | digits: 3
```

::: predict
## A matrix $A$ is rewritten in a new basis as $B = M^{-1}AM$. Which of these stays the same?

- [ ] The entries
- [x] The eigenvalues
- [ ] The eigenvectors' coordinates
- [ ] Nothing in particular

::: reveal
The eigenvalues. $B$ describes the same transformation as $A$, just in different coordinates, and a stretch factor along a direction doesn't depend on how you label points. The eigenvectors are the same arrows too, but their coordinates change: $B$'s eigenvectors are $M^{-1}$ times $A$'s. The trace and determinant, built from the eigenvalues, stay the same as well.
:::
:::

::: nameit
## Linear transformations

A **linear transformation** $T$ takes vectors to vectors and respects combinations:

$$T(c\mathbf{v} + d\mathbf{w}) = cT(\mathbf{v}) + dT(\mathbf{w})$$

Rotations, projections, stretches and derivatives are all linear. Choose a basis, record where $T$ sends each basis vector as a column, and you have $T$'s **matrix in that basis**.

For example, on polynomials of degree at most 2 with basis $1, x, x^2$, the derivative sends $1 \to 0$, $x \to 1$, $x^2 \to 2x$:

$$D = \begin{bmatrix}0 & 1 & 0\\0 & 0 & 2\\0 & 0 & 0\end{bmatrix}$$

## Change of basis

If the columns of $M$ are a new basis, a vector with new coordinates $\mathbf{c}$ is $M\mathbf{c}$ in the old ones, so $\mathbf{c} = M^{-1}\mathbf{v}$. A transformation with matrix $A$ in the old basis has matrix

$$B = M^{-1}AM$$

in the new one: convert to old coordinates, apply $A$, convert back. $A$ and $B$ are **similar**: same eigenvalues, trace, determinant and rank.

**The best basis** is usually the eigenvectors, where $B = \Lambda$ is diagonal (lesson 34), or for a symmetric matrix the orthonormal eigenvectors, where $M^{-1} = M^T$.

## The Park transform

After the Clarke transform (lesson 18), a balanced three-phase set is a vector $(v_\alpha, v_\beta) = V(\cos\theta, \sin\theta)$ turning at the line frequency. Express it in a basis that rotates with angle $\theta$:

$$\begin{bmatrix}v_d\\v_q\end{bmatrix} = \begin{bmatrix}\cos\theta & \sin\theta\\-\sin\theta & \cos\theta\end{bmatrix}\begin{bmatrix}v_\alpha\\v_\beta\end{bmatrix}$$

The result is constant. Field-oriented motor control and grid-tied inverters (S11, S12) regulate $v_d$ and $v_q$ with ordinary DC controllers.
:::

::: example
## Find the matrix of $T(\mathbf{x}) = $ reflection across the line $y = x$, in the standard basis and in the basis $(1, 1), (1, -1)$.

::: solution
1. **Standard basis.** $(1, 0) \to (0, 1)$ and $(0, 1) \to (1, 0)$, so
   $$A = \begin{bmatrix}0 & 1\\1 & 0\end{bmatrix}$$
2. **New basis.** $(1, 1)$ lies on the line and stays put; $(1, -1)$ is perpendicular and flips. So
   $$B = \begin{bmatrix}1 & 0\\0 & -1\end{bmatrix}$$
3. **Compare.** Same reflection, much simpler matrix, because the new basis is its eigenvectors.

**Answer:** $A = \begin{bmatrix}0 & 1\\1 & 0\end{bmatrix}$ in the standard basis and $B = \begin{bmatrix}1 & 0\\0 & -1\end{bmatrix}$ in the basis $(1, 1), (1, -1)$.
:::
:::

::: example
## A balanced set with peak 170 V leads the reference angle by 30°. What are $v_d$ and $v_q$?

::: solution
1. **The alpha-beta components.**
   $$\begin{aligned} v_\alpha &= 170\cos(\theta + 30°) \\ v_\beta &= 170\sin(\theta + 30°) \end{aligned}$$
2. **Rotate by $-\theta$.** That removes $\theta$, leaving
   $$\begin{aligned} v_d &= 170\cos 30° \\ &= 147.2\ \text{V} \\ v_q &= 170\sin 30° \\ &= 85\ \text{V} \end{aligned}$$
   both constant.

**Answer:** $v_d$ = 147.2 V and $v_q$ = 85 V, both constant.
:::
:::

::: example
## Find the matrix of differentiation on polynomials of degree at most 2, in the basis $1, x, x^2$.

::: solution
1. **It has a matrix.** Differentiation is linear, so it has a matrix, whose columns are the images of the basis.
2. **Images of the basis.**
   $$\tfrac{d}{dx}1 = 0, \quad \tfrac{d}{dx}x = 1, \quad \tfrac{d}{dx}x^2 = 2x$$
3. **In coordinates.**
   $$D = \begin{bmatrix}0 & 1 & 0\\0 & 0 & 2\\0 & 0 & 0\end{bmatrix}$$
4. **Its properties.** Its null space is the constants and its rank is 2. Also, $D^3 = 0$: differentiating a quadratic three times leaves nothing.

**Answer:** $D$ has rows $(0, 1, 0)$, $(0, 0, 2)$ and $(0, 0, 0)$.
:::
:::

::: check
given: n = 2 | 3; let n1 = n + 1
answer: n

## In the basis $1, x, x^2, x^3$, what is the entry of the derivative's matrix in row {n}, column {n1}?

::: right
Right. The derivative sends $x^n$ to $nx^{n-1}$, which puts $n$ = {answer} in that position.
:::

::: misses
- [n + 1] Column $n + 1$ holds the image of $x^n$, which is $nx^{n-1}$.
- [1] Differentiating brings the power down as a coefficient.
- [any] Not yet. Where does $D$ send $x^{\given{n}}$?
:::
:::

::: check
given: v1 = 3 | 5; v2 = 1 | -2
answer: v1 - v2

## The basis is $(1, 0)$ and $(1, 1)$. What is the first coordinate of $\mathbf{v} = (\given{v1}, \given{v2})$ in it?

::: right
Right. $c_1(1, 0) + c_2(1, 1) = (v_1, v_2)$ gives $c_2 = v_2$ and $c_1 = v_1 - v_2$ = {answer}.
:::

::: misses
- [v1] The second basis vector contributes to the first component too.
- [v2] That's the second coordinate.
- [any] Not yet. Solve $M\mathbf{c} = \mathbf{v}$.
:::
:::

::: check
given: t = 5 | -2; d = 6 | 3
answer: t

## $A$ has trace {t} and determinant {d}. What is the trace of $M^{-1}AM$?

::: right
Right. Similar matrices have the same eigenvalues, so the same trace: {answer}.
:::

::: misses
- [d] That's the determinant, which also stays the same.
- [any] Not yet. What does a change of basis do to the eigenvalues?
:::
:::

::: check
given: V = 100 | 170; p = 20 | 60
answer: V*cos(p*pi/180)
unit: V
tolerance: 0.5%

## A balanced three-phase set with peak {V} V leads the reference angle by {p}°. What is $v_d$?

::: right
Right. In the rotating frame only the {p}° offset remains: $v_d = V\cos\varphi$ = {answer}.
:::

::: misses
- [V*sin(p*pi/180)] That's $v_q$.
- [V] That's when the offset is zero.
- [any] Not yet. Rotate by $-\theta$: what angle is left?
:::
:::

::: check
kind: choice

## In the basis of its eigenvectors, what does the matrix of a projection onto a line in the plane look like?

- [x] $\begin{bmatrix}1 & 0\\0 & 0\end{bmatrix}$
- [ ] $\begin{bmatrix}1 & 0\\0 & 1\end{bmatrix}$
- [ ] $\begin{bmatrix}0 & 1\\1 & 0\end{bmatrix}$
- [ ] $\begin{bmatrix}1 & 1\\0 & 0\end{bmatrix}$

::: right
Right. Vectors along the line stay put (eigenvalue 1) and vectors perpendicular to it go to zero (eigenvalue 0).
:::

::: misses
- [2] That's the identity: it would leave everything unchanged.
- [any] What happens to a vector along the line, and to one perpendicular to it?
:::
:::

::: check
given: s = 0.9 | 1.1 | 0.5
answer: 2*pi/abs(1 - s)
unit: s
tolerance: 0.5%

## The vector turns at 1 rad/s and the frame at {s} rad/s. How long does the vector take to go once around, as seen from the frame?

::: right
Right. The relative speed is $|1 - s|$, so one turn takes $\frac{2\pi}{|1 - s|}$ = {answer}.
:::

::: misses
- [2*pi] That's in the stationary frame.
- [2*pi/(1 + s)] The frame turns the same way, so the speeds subtract.
- [any] Not yet. Use the relative angular speed.
:::
:::

::: check
kind: parts
given: a = 2 | 3; b = 1 | 4

## $T$ has matrix $\begin{bmatrix}\given{a} & 0\\0 & \given{b}\end{bmatrix}$ in the basis $\mathbf{v}_1 = (1, 1)$, $\mathbf{v}_2 = (1, -1)$.

::: part
answer: (a + b)/2
tolerance: 0.5%

### What is the $x$ coordinate of $T(1, 0)$?

::: misses
- [a] First write $(1, 0) = \frac12\mathbf{v}_1 + \frac12\mathbf{v}_2$.
- [any] $T(1, 0) = \frac a2\mathbf{v}_1 + \frac b2\mathbf{v}_2$.
:::
:::

::: part
answer: (a - b)/2
tolerance: 0.5%

### And its $y$ coordinate?

::: misses
- [any] $\frac a2 - \frac b2$.
:::
:::
:::

::: check
kind: derivation
vars: b = -3..3, c = -3..3

## Differentiate $a + bx + cx^2$ using the matrix $D$ in the basis $1, x, x^2$.

::: step
answer: b

### What is the constant term of the result?
:::

::: step
answer: 2*c

### What is the coefficient of $x$?
:::

::: right
Right. $D(a, b, c) = (b, 2c, 0)$: the matrix does what calculus does.
:::
:::

::: explain
## Why do similar matrices $A$ and $M^{-1}AM$ have the same eigenvalues?

::: model
They describe the same transformation in two different coordinate systems. If $A\mathbf{x} = \lambda\mathbf{x}$, then $M^{-1}AM(M^{-1}\mathbf{x}) = M^{-1}A\mathbf{x} = \lambda M^{-1}\mathbf{x}$, so $M^{-1}\mathbf{x}$ is an eigenvector of the new matrix with the same eigenvalue. Algebraically, $\det(M^{-1}AM - \lambda I) = \det(M^{-1}(A - \lambda I)M) = \det(A - \lambda I)$. A stretch factor along a direction is a geometric fact, independent of the coordinates used to describe it.
:::
:::

::: practice

::: check
given: v1 = 5 | 7; v2 = 2 | -3
answer: v2

## The basis is $(1, 0)$ and $(1, 1)$. What is the second coordinate of $(\given{v1}, \given{v2})$?

::: misses
- [v1 - v2] That's the first coordinate.
- [any] Only $(1, 1)$ has a second component.
:::
:::

::: check
given: V = 120 | 300; p = 30 | 60
answer: V*sin(p*pi/180)
unit: V
tolerance: 0.5%

## A balanced set with peak {V} V leads the reference by {p}°. What is $v_q$?

::: misses
- [V*cos(p*pi/180)] That's $v_d$.
- [any] $V\sin\varphi$.
:::
:::

::: check
given: d = -9 | -7 | -3 | 2 | 4 | 5 | 11
answer: d

## $\det A$ = {d}. What is $\det(M^{-1}AM)$?

::: misses
- [any] Similar matrices share their determinant.
:::
:::
:::
