# 3blue1brown's visually doing linear transformations composition

I am trying to understand the step-by-step of visually calculating linear transformations following 3blue1brown chapter 4 (see youtube 3blue1brown ch 4.

Background: 3blue1brown describes how we can visually capture one transformation by simply recording where the base vectors ($$\hat{i}, \hat{j}$$) land in the original coordinate system. So a rotation will produce new base vecors:

$$\left[\begin{array}{cc} 0 & -1 \\ 1 & 0 \\ \end{array} \right]$$

where the first column captures the new base for $$\hat{i}$$ and the second column is the new base for $$\hat{j}$$. Following one transformation visually like this is straightforward. Conducting two transformations should produce similar results. But I am not getting consistent results.

For example, take the two transformations "first do a rotation, then do a sheer transformation"--see the link above for visuals. I interpret this as firs do the rotation and draw this new coordinate system: the new x-axis points vertically and the y-axis points horizontally. Call the new base vectors $$\hat{i_r}$$ and $$\hat{j_r}$$. Now we do a sheer transformation in this new coordinate system and record where $$\hat{i_r}$$ and $$\hat{j_r}$$ land: call these new base vectors $$\hat{i_s}$$ and $$\hat{j_s}$$. I record where $$\hat{i_s}$$ and $$\hat{j_s}$$ land in the original (non-transformed) coordinate system. This would give me a new (composition) matrix:

$$\left[\begin{array}{cc} 0 & -1 \\ 1 & 1 \\ \end{array} \right]$$

This is obviously wrong since the composition matrix should be:

$$\left[\begin{array}{cc} 1 & -1 \\ 1 & 0 \\ \end{array} \right]$$

A sheer transformation is represented by:

$$\left[\begin{array}{cc} 1 & 1 \\ 0 & 1 \\ \end{array} \right]$$

A rotation transformation by,

$$\left[\begin{array}{cc} 0 & -1 \\ 1 & 0 \\ \end{array} \right]$$

Why does this visual-way of doing it ste-by-step not adding up? Curiously, if you do these two linear transformations backward, you do in fact get the expected results. In other words, the visual calculation of "first do a rotation, then do a sheer transformation", will produce the correct answer if we do first a sheer, then do a rotation in the sheer coordinate system, then record where the base vectors land in the original (non-transsformed) coordinate system. But this is counterintuitive of that order matters in doing linear transformations.

• What is your rotation and sheer? Can't verify your calculations without knowing what transformation you wish to represent – Brevan Ellefsen Feb 24 at 20:11
• Thanks for your input. Clarified the rotation and sheer transformation. – Adel Feb 24 at 20:51

I think we can consider this question in this way.

The matrix which does the rotation is then

$$T = \begin{bmatrix} 0 & -1\\ 1 & 0 \end{bmatrix}$$

Then we do the shear transform. In the rotated system, the coordinates of two base vectors become $$\hat{i}=\begin{bmatrix}1\\-1\end{bmatrix}$$ and $$\hat{j}=\begin{bmatrix}0\\1\end{bmatrix}$$. So the transform is

$$S = \begin{bmatrix} 1 & 0\\ -1 & 1 \end{bmatrix}$$

But we are in the transformed system. If we see this shear in the original system, it would be like

$$T\cdot{S} = \begin{bmatrix} 0 & -1\\ 1 & 0 \end{bmatrix} \begin{bmatrix} 1 & 0\\ -1 & 1 \end{bmatrix} = \begin{bmatrix} 1 & -1\\ 1 & 0 \end{bmatrix}$$

which is the composition of two transforms.

Hope this will help.

Update:

When we talk about a vector, say, $$v = \begin{bmatrix}3\\4\end{bmatrix}$$, we talk about it in the standard basis. I.e., $$v = 3\hat{i} + 4\hat{j}$$ or $$v=\begin{bmatrix}\hat{i}&\hat{j}\end{bmatrix}\begin{bmatrix}3\\4\end{bmatrix}$$.

First, we do the rotation. Base vectors change from $$\hat{i}$$, $$\hat{j}$$ to $$\hat{i}' = \hat{j}$$, $$\hat{j}' = -\hat{i}$$.

$$T = \begin{bmatrix} \hat{i}' & \hat{j}' \end{bmatrix} = \begin{bmatrix} \hat{j} & -\hat{i} \end{bmatrix}$$

Then we do the shear transform. Here for base vectors, $$\hat{i}'' = \hat{i}' - \hat{j}'$$, $$\hat{j}'' = \hat{j}'$$

$$S = \begin{bmatrix} \hat{i}'' & \hat{j}'' \end{bmatrix} = \begin{bmatrix} \hat{i}' - \hat{j'} & \hat{j}' \end{bmatrix}$$

But as you can see our base vectors are based on $$\hat{i}'$$ and $$\hat{j}'$$ instead of $$\hat{i}$$ and $$\hat{j}$$. So this only describes the shear transform in terms of the rotated system. But we know the relationship between them from the rotation transform. So we can get the transform

$$T'= \begin{bmatrix} \hat{i} + \hat{j} & -\hat{i} \end{bmatrix}$$

which describes a rotation and a shear directly.

• Thanks @Snjór! I guess where I am stuck is the part of visually seeing that the two base vectors in the rotated system are actually i = (1,-1) and j = (0,1)--your S matrix. How do we actually realize this geometrically? I am led to see these as i = (1,1), j = (-1,1). I am missing some obvious part... – Adel Feb 24 at 22:43
• @Adel I updated my answer. Hope it makes some sense. – Snjór Feb 25 at 23:01