Linear Algebra and Its Applications, Exercise 2.6.7

Exercise 2.6.7. Describe the matrices representing the following transformations:

i) projecting all vectors onto the xy plane

ii) reflecting all vectors through the xy plane

iii) rotating all vectors in the xy plane by 90 degrees, leaving the z axis unchanged

iv) rotating the xy plane by 90 degrees, followed by rotating the xz plane by 90 degrees, and finally rotating the yz plane by 90 degrees

v) again carrying out the three rotations in succession, but through 180 degrees each time instead

Answer: i) The following matrix projects all vectors onto the xy plane:

\begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&0 \end{bmatrix}

Note that this has the effect of multiplying the z components of all vectors by zero, and multiplying the x and y components by the identity matrix:

\begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&0 \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} = \begin{bmatrix} v_1 \\ v_2 \\ 0 \end{bmatrix}

ii) The following matrix reflects all vectors through the xy plane:

\begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&-1 \end{bmatrix}

Note that this has the effect of negating the z components of all vectors, and multiplying the x and y components by the identity matrix:

\begin{bmatrix} 1&0&0 \\ 0&1&0 \\ 0&0&-1 \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} = \begin{bmatrix} v_1 \\ v_2 \\ -v_3 \end{bmatrix}

iii) In order to carry out this transformation, we start with the 2 by 2 matrix for rotation in the xy plane by 90 degrees:

\begin{bmatrix} \cos 90^{\circ}&-\sin 90^{\circ} \\ \sin 90^{\circ}&\cos 90^{\circ} \end{bmatrix} = \begin{bmatrix} 0&-1 \\ 1&0 \end{bmatrix}

Moving to three dimensions, the following matrix rotates all vectors in the xy plane by 90 degrees, leaving the z components alone:

\begin{bmatrix} 0&-1&0 \\ 1&0&0 \\ 0&0&1 \end{bmatrix}

Note that this has the effect of preserving the z components of all vectors, and multiplying the x and y components by the 2 by 2 matrix for a 90 degree rotation:

\begin{bmatrix} 0&-1&0 \\ 1&0&0 \\ 0&0&1 \end{bmatrix} \begin{bmatrix} v_1 \\ v_2 \\ v_3 \end{bmatrix} = \begin{bmatrix} -v_2 \\ v_1 \\ v_3 \end{bmatrix}

iv) In order to carry out this transformation, we first use the matrix from the previous exercise that rotates all vectors in the xy plane by 90 degrees, leaving the z components alone:

\begin{bmatrix} 0&-1&0 \\ 1&0&0 \\ 0&0&1 \end{bmatrix}

We then use the matrix that rotates all vectors in the xz plane by 90 degrees, leaving the y components alone:

\begin{bmatrix} 0&0&-1 \\ 0&1&0 \\ 1&0&0 \end{bmatrix}

Note that this matrix is constucted by taking the 2 by 2 matrix for rotation by 90 degrees in the xz plane and extending it to three dimensions to leave the y components as is.

Finally we use the matrix that rotates all vectors in the yz plane by 90 degrees, leaving the x components alone:

\begin{bmatrix} 1&0&0 \\ 0&0&-1 \\ 0&1&0 \end{bmatrix}

We perform all three rotations by multiplying the matrices in reverse order:

\begin{bmatrix} 1&0&0 \\ 0&0&-1 \\ 0&1&0 \end{bmatrix} \begin{bmatrix} 0&0&-1 \\ 0&1&0 \\ 1&0&0 \end{bmatrix} \begin{bmatrix} 0&-1&0 \\ 1&0&0 \\ 0&0&1 \end{bmatrix}

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

Note that this transformation is equivalent to rotating all vectors in the xz plane by 90 degrees, leaving the y component unchanged.

v) In order to carry out this transformation, we start with the 2 by 2 matrix for rotation in the xy plane by 180 degrees:

\begin{bmatrix} \cos 180^{\circ}&-\sin 180^{\circ} \\ \sin 180^{\circ}&\cos 180^{\circ} \end{bmatrix} = \begin{bmatrix} -1&0 \\ 0&-1 \end{bmatrix}

Moving to three dimensions, we first use the matrix that rotates all vectors in the xy plane by 180 degrees, leaving the z components alone:

\begin{bmatrix} -1&0&0 \\ 0&-1&0 \\ 0&0&1 \end{bmatrix}

We then use the matrix that rotates all vectors in the xz plane by 180 degrees, leaving the y components alone:

\begin{bmatrix} -1&0&0 \\ 0&1&0 \\ 0&0&-1 \end{bmatrix}

Finally we use the matrix that rotates all vectors in the yz plane by 180 degrees, leaving the x components alone:

\begin{bmatrix} 1&0&0 \\ 0&-1&0 \\ 0&0&-1 \end{bmatrix}

We perform all three rotations by multiplying the matrices in reverse order:

\begin{bmatrix} 1&0&0 \\ 0&-1&0 \\ 0&0&-1 \end{bmatrix} \begin{bmatrix} -1&0&0 \\ 0&1&0 \\ 0&0&-1 \end{bmatrix} \begin{bmatrix} -1&0&0 \\ 0&-1&0 \\ 0&0&1 \end{bmatrix}

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

Note that this transformation is equivalent to multiplying a vector by the identity matrix, leaving it unchanged.

UPDATE: Corrected the calculation of the cumulative effect of the three rotations in the answer to (iv). Thanks to Ji for pointing out my error.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | 2 Comments

Linear Algebra and Its Applications, Exercise 2.6.6

Exercise 2.6.6. Suppose we have a transformation matrix

A = \begin{bmatrix} 1&0 \\ 3&1 \end{bmatrix}

This is a shearing transformation: it leaves unchanged any points (x, y) for which x = 0 and thus leaves unchanged the entire y-axis. Describe how this transformation affects the x-axis, including the points (1, 0), (2, 0), and (-1, 0).

Answer: For the point (1, 0) we have

\begin{bmatrix} 1&0 \\ 3&1 \end{bmatrix} \begin{bmatrix} 1 \\ 0 \end{bmatrix} = \begin{bmatrix} 1 \\ 3 \end{bmatrix}

For the point (2, 0) we have

\begin{bmatrix} 1&0 \\ 3&1 \end{bmatrix} \begin{bmatrix} 2 \\ 0 \end{bmatrix} = \begin{bmatrix} 2 \\ 6 \end{bmatrix}

For the point (-1, 0) we have

\begin{bmatrix} 1&0 \\ 3&1 \end{bmatrix} \begin{bmatrix} -1 \\ 0 \end{bmatrix} = \begin{bmatrix} -1 \\ -3 \end{bmatrix}

Based on these examples it appears that the matrix A transforms the x-axis into a line through the origin with slope 3.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

Linear Algebra and Its Applications, Exercise 2.6.5

Exercise 2.6.5. Suppose we have two points x and y and a third point z halfway between the first two points. Show that for any linear transformation represented by a matrix A the (transformed) point Az is halfway between Ax and Ay.

Answer: If z is halfway between x and y then we have z = \frac{1}{2}(x + y).  For example, if x = (1, 2) and y = (3, 8) then

z = \frac{1}{2}(\begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} 3 \\ 8 \end{bmatrix}) = \frac{1}{2} \begin{bmatrix} 4 \\ 10 \end{bmatrix} = \begin{bmatrix} 2 \\ 5 \end{bmatrix}

We then have

Az = A(\frac{1}{2}(x+y)) = \frac{1}{2}A(x+y) = \frac{1}{2}(Ax+Ay)

But this implies that Az is halfway between Ax and Ay, which is what we were asked to show.

For example, suppose that

A = \begin{bmatrix} 1&2 \\ -1&1 \end{bmatrix}

Then using our example points above we have

Ax = \begin{bmatrix} 1&2 \\ -1&1 \end{bmatrix} \begin{bmatrix} 1 \\ 2 \end{bmatrix} = \begin{bmatrix} 5 \\ 1 \end{bmatrix}

Ay = \begin{bmatrix} 1&2 \\ -1&1 \end{bmatrix} \begin{bmatrix} 3 \\ 8 \end{bmatrix} = \begin{bmatrix} 19 \\ 5 \end{bmatrix}

Az = \begin{bmatrix} 1&2 \\ -1&1 \end{bmatrix} \begin{bmatrix} 2 \\ 5 \end{bmatrix} = \begin{bmatrix} 12 \\ 3 \end{bmatrix}

\frac{1}{2}(Ax+Ay) = \frac{1}{2}(\begin{bmatrix} 5 \\ 1 \end{bmatrix} + \begin{bmatrix} 19 \\ 5 \end{bmatrix}) = \frac{1}{2} \begin{bmatrix} 24 \\ 6 \end{bmatrix} = \begin{bmatrix} 12 \\ 3 \end{bmatrix} = Az

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

Linear Algebra and Its Applications, Exercise 2.6.4

Exercise 2.6.4. Consider the matrix

A = \begin{bmatrix} 2&0 \\ 0&1 \end{bmatrix}

This matrix will “stretch” vectors along the x axis, transforming the vector v = (x, y) into the vector v' = (2x, y). Consider also the circle formed by all points for which x^2 + y^2 = 1. What shape is the curve created by transforming all points on the circle by A?

Answer: Transforming the points on the circle using A has the effect of stretching the circle horizontally while keeping the vertical height the same. Points to the right of the y-axis (for which x is positive) get stretched in a positive direction, while points to the left of the y-axis (for which x is negative) get stretched in a negative direction. The resulting (closed) curve appears to be an ellipse symmetric about the two axes.

We can confirm that the new curve is an ellipse by showing that points on the curve satisfy the equation

(x/a)^2 + (y/b)^2 = 1

for some a and b. We know that for all points v = (x, y) on the original circle we have x^2 + y^2 = 1. After multiplying by A for all points v' = (x', y') on the new curve we have x' = 2x and y' = y. Since x' = 2x we have x = x'/2.

We then have

1 = x^2 + y^2 = (x'/2)^2 + (y'/1)^2

so that

(x'/a)^2 + (y'/b)^2 = 1

for a = 2 and b = 1. The new curve is thus an ellipse.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

Linear Algebra and Its Applications, Exercise 2.6.3

Exercise 2.6.3. Suppose we form the product of  2 by 2 matrices representing 5 reflections and 8 rotations. Does that product matrix represent a reflection or a rotation?

Answer: I’ll show a long way to the answer and then a shorter (and more general) way. First, the long way:

Let Q_1 through Q_8 be the 8 rotation matrices and H_1 through H_5 the 5 reflection matrices. Note that the question is a bit ambiguous as to whether the reflections or rotations are done first; we assume that the reflections are done first, so that the product matrix A is calculated as

A = Q_8 Q_7 Q_6 Q_5 Q_4 Q_3 Q_2 Q_1 H_5 H_4 H_3 H_2 H_1

(As I discuss below regarding the simpler way to an answer, whether the reflections come first or the rotations doesn’t actually matter.)

Since matrix multiplication is associative we can do the multiplications as follows:

A = (Q_8 Q_7) (Q_6 Q_5) (Q_4 Q_3) (Q_2 Q_1) H_5 (H_4 H_3) (H_2 H_1)

From the previous post on composing reflections and rotations we know that the product of two rotations is a rotation, and the product of two reflections is also a rotation. The above equation thus reduces to

A = Q_9 Q_{10} Q_{11} Q_{12} H_5 Q_{13} Q_{14}

where Q_9 is a rotation matrix formed by the product of Q_8 and Q_7, Q_{14} is a rotation matrix formed by the product of H_2 and H_1, and Q_{10} through Q_{13} are calculated similarly.

We can further reduce this as follows:

A = (Q_9 Q_{10}) (Q_{11} Q_{12}) H_5 (Q_{13} Q_{14}) = Q_{15} H_5 Q_{16}

where Q_{15} is a rotation matrix formed by the product of Q_{9} and Q_{10} and Q_{16} is the rotation matrix formed by the product of Q_{13} and Q_{14}.

Finally, we know from the previous post that the product of a reflection and a rotation (or a rotation and a reflection) is a reflection, so we can reduce the previous equation to

A = (Q_{15} H_5) Q_{12} = H_6 Q_{16} = H_7

where H_{6} is a reflection matrix formed by the product of Q_{15} and H_5 and H_{7} is a reflection matrix formed by the product of H_6 and Q_{16}. So the product of 5 reflections and 8 rotations is a reflection.

Now for the shorter way, which can be used no matter the number of rotations and reflections:

Note first that the product of any number of rotation matrices will itself be a rotation matrix. This follows straightforwardly by induction from the fact that the product of two rotation matrices is a rotation matrix.

Then note that the product of an even number of reflection matrices will be a rotation matrix. This is because we can pair up the reflection matrices, multiply the two matrices in each pair to produce a rotation matrix, and then multiply the resulting rotation matrices (no matter how many there are) to produce a rotation matrix.

Finally, note that the product of an odd number of reflection matrices will be a reflection matrix: We can take all reflection matrices except the last one and multiply them; since there will an even number of reflection matrices this will produce a rotation matrix, as discussed in the previous paragraph. We then take this rotation matrix and multiply it by the remaining reflection matrix to produce a reflection matrix.

So, if we have the product of 5 reflections and 8 rotations, the 8 rotations will produce a rotation, the 5 reflections will produce a reflection (since 5 is odd), and the product of the resulting rotation and reflection matrices will produce a reflection.

Note that it is irrelevant whether the rotations are done first or the reflections. In either case the 8 rotations will reduce to a rotation and the 5 reflections will reduce to a reflection, and the product of a rotation and a reflection is a reflection no matter in which order the matrices are multiplied.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

A summary of the effects of rotations and reflections

This post summarizes the results of previous posts exploring the effects of the following sequences of linear transformations in the x-y plane:

To review, the linear transformation that rotates vectors through an angle \theta can be represented by the matrix

Q_{\theta} = \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix}

The linear transformation that reflects vectors in the line through the origin with angle \varphi (the \varphi-line) can be represented by the matrix

H_{\varphi} = \begin{bmatrix} 2\cos^2 \varphi - 1&2\cos\varphi\sin\varphi \\ 2\cos\varphi\sin\varphi&2\sin^2 \varphi - 1 \end{bmatrix}

= \begin{bmatrix} \cos 2\varphi&\sin 2\varphi \\ \sin 2\varphi&-\cos 2\varphi \end{bmatrix}

Combining these operations (for example, to do a rotation followed by a reflection) is done by multiplying from the left by the matrix representing the first operation (in this case, a rotation) and then multiplying from the left again by the matrix representing the second operation (in this case, a reflection).

We then have the following results:

  • A rotation followed by a rotation is a rotation: Q_\varphi Q_\theta = Q_{\varphi+\theta}
  • A reflection followed by a reflection is a rotation: H_\varphi Q_\theta = Q_{2(\varphi - \theta)}
  • A rotation followed by a reflection is a reflection: H_\varphi Q_\theta = H_{\varphi-\frac{1}{2}\theta}
  • A reflection followed by a rotation is a reflection: Q_\theta H_\varphi = H_{\varphi+\frac{1}{2}\theta}

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

A reflection followed by a rotation is a reflection

In preparation for answering exercise 2.6.3 in Gilbert Strang’s Linear Algebra and Its Applications, Third Edition, I wanted to derive in detail the effect of a rotation followed by a rotation, a reflection followed by a reflection, a rotation followed by a reflection, and a reflection followed by a rotation. This post demonstrates that a reflection followed by a rotation is equivalent to a reflection.

In the last post we considered a matrix Q_{\theta} that rotates vectors through an angle \theta and a second matrix H_{\varphi} that reflects vectors in the line through the origin with angle \varphi (the \varphi-line). We showed that H_\varphi Q_\theta = H_{\varphi-\frac{1}{2}\theta} so that the effect of applying a rotation of angle \theta followed by a reflection through the \varphi-line is equivalent to a reflection through the (\varphi - \frac{1}{2}\theta)-line:

H_\varphi Q_\theta= \begin{bmatrix} \cos 2\varphi&\sin 2\varphi \\ \sin 2\varphi&-\cos 2\varphi \end{bmatrix} \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix}

= \begin{bmatrix} \cos 2(\varphi - \frac{1}{2}\theta)&\sin 2(\varphi - \frac{1}{2}\theta) \\ \sin 2(\varphi - \frac{1}{2}\theta)&-\cos 2(\varphi - \frac{1}{2}\theta)\end{bmatrix} = H_{\varphi-\frac{1}{2}\theta}

Consider the reverse operation represented by the matrix Q_\theta H_\varphi in which we first reflect vectors in the line through the origin with angle \varphi (the \varphi-line) and then rotate vectors through an angle \theta. We have

Q_\theta H_\varphi = \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix} \begin{bmatrix} \cos 2\varphi&\sin 2\varphi \\ \sin 2\varphi&-\cos 2\varphi \end{bmatrix}

= \begin{bmatrix} \cos\theta\cos 2\varphi - \sin\theta\sin 2\varphi&\cos\theta\sin 2\varphi + \sin\theta\cos 2\varphi \\ \sin\theta\cos 2\varphi + \cos\theta\sin 2\varphi&\sin\theta\sin 2\varphi - \cos\theta\cos 2\varphi \end{bmatrix}

We can simplify this using the trigonometric identities

\begin{array}{rcl} \cos (\alpha + \beta)&=&\cos \alpha \cos \beta - \sin \alpha \sin \beta \\ \sin (\alpha + \beta)&=&\sin \alpha \cos \beta + \cos \alpha \sin \beta \end{array}

We then have

Q_\theta H_\varphi = \begin{bmatrix} \cos\theta\cos 2\varphi-\sin\theta\sin 2\varphi&\sin\theta\cos 2\varphi+\cos\theta\sin 2\varphi \\ \sin\theta\cos 2\varphi+\cos\theta\sin 2\varphi&-(\cos\theta\cos 2\varphi-\sin\theta\sin 2\varphi) \end{bmatrix}

= \begin{bmatrix} \cos (\theta+2\varphi)&\sin (\theta+2\varphi) \\ \sin (\theta+2\varphi)&-\cos (\theta+2\varphi) \end{bmatrix}

= \begin{bmatrix}\cos 2(\varphi+\frac{1}{2}\theta)&\sin 2(\varphi + \frac{1}{2} \theta) \\ \sin 2(\varphi + \frac{1}{2} \theta)&-\cos 2(\varphi + \frac{1}{2} \theta \end{bmatrix} = H_{\varphi+\frac{1}{2}\theta}

We have thus shown that Q_\theta H_\varphi = H_{\varphi+\frac{1}{2}\theta} so that the effect of applying a reflection through the \varphi-line followed by a rotation of angle \theta is equivalent to a reflection through the (\varphi + \frac{1}{2}\theta)-line.

If \theta= 0 then this equation reduces to Q_0 H_\varphi = H_{\varphi+\frac{1}{2} \cdot 0} or H_\varphi = H_\varphi since Q_0 = I.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

A rotation followed by a reflection is a reflection

In preparation for answering exercise 2.6.3 in Gilbert Strang’s Linear Algebra and Its Applications, Third Edition, I wanted to derive in detail the effect of a rotation followed by a rotation, a reflection followed by a reflection, a reflection followed by a rotation, and a rotation followed by a reflection. This post demonstrates that a rotation followed by a reflection is equivalent to a reflection.

Assume that we have a matrix that rotates vectors through an angle \theta and a second matrix that reflects vectors in the line through the origin with angle \varphi (the \varphi-line). What is the effect of applying both matrices in succession?

As we did with a reflection followed by a reflection, we can try to gain an intuition about the problem by playing with a cut-out paper triangle on a piece of paper marked with axes. After trying this you should find that a rotation followed by a reflection will apparently cause the triangle to be reflected from its original position. (One hint here is that the triangle will end up as a mirror image of the original triangle.)

If this is indeed the case then the effect of a rotation through the angle \theta and a reflection in the \varphi-line can be represented by a matrix

Q_\omega = \begin{bmatrix} \cos 2\omega&\sin 2\omega \\ \sin 2\omega&-\cos 2\omega \end{bmatrix}

for a line of reflection through the origin with some angle \omega. (Here we use the expression for a reflection matrix derived in the last post.)

How does the angle \omega relate to the angles \theta and \varphi? Since we are dealing with linear transformations the simplest assumption is that \omega = a\theta + b\varphi for some a and b where a and b are the same for all \theta and \varphi.

To determine the values of a and b let’s look at the unit vector (1, 0) and rotate it and reflect it. In the first case we rotate the vector 90^{\circ} and then reflect it in the 135^{\circ}-line (the line for which y = -x). The rotation takes (1,0) to (0,1) and the reflection takes (0,1) to (-1, 0). The corresponding line of reflection is  the 90^{\circ}-line (the y-axis).

In the second case we rotate vector (1,0) 180^{\circ} and then reflect it in the 45^{\circ}-line (the line for which y = x). The rotation takes (1,0) to (-1,0) and the reflection takes (-1,0) to (0,-1). The corresponding line of reflection is  the 325^{\circ}-line (equivalent to the -45^{\circ}-line).

If the angle of rotation \omega = a\theta + b\varphi then in the first case we would have 90 = 90a + 135b and in the second case we would have -45 = 180a + 45b. Subtracting 2 times the first equation from the second we have -225 = -225b or b = 1. Substituting the value of b into the first equation we have 90 = 90a + 135 or a = -\frac{1}{2}.

Our hypothesis is therefore that doing a rotation through the angle \theta and then a reflection through the \varphi-line would produce a reflection through the line of angle \omega = -\frac{1}{2}\theta + \varphi = \varphi -\frac{1}{2}\theta. If this is the case then the matrix representing the reflection would be

H_{\varphi-\frac{1}{2}\theta} = \begin{bmatrix} \cos 2(\varphi-\frac{1}{2}\theta)&\sin 2(\varphi-\frac{1}{2}\theta) \\ \sin 2(\varphi-\frac{1}{2}\theta)&-\cos 2(\varphi-\frac{1}{2}\theta) \end{bmatrix}

= \begin{bmatrix} \cos (2\varphi-\theta)&\sin (2\varphi-\theta) \\ \sin (2\varphi-\theta)&-\cos (2\varphi-\theta) \end{bmatrix}

and this matrix should be equal to the product of the matrices corresponding to the rotation and the reflection:

H_\varphi Q_\theta = \begin{bmatrix} \cos 2\varphi&\sin 2\varphi \\ \sin 2\varphi&-\cos 2\varphi \end{bmatrix} \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix}

= \begin{bmatrix} \cos 2\varphi \cos \theta + \sin 2\varphi \sin \theta&-\cos 2\varphi \sin \theta + \sin 2\varphi \cos \theta \\ \sin 2\varphi \cos \theta - \cos 2\varphi \sin \theta&-\sin 2\varphi \sin \theta - \cos 2\varphi \cos \theta \end{bmatrix}

We can simplify this using the trigonometric identities

\begin{array}{rcl} \cos (\alpha - \beta)&=&\cos \alpha \cos \beta + \sin \alpha \sin \beta \\ \sin (\alpha - \beta)&=&\sin \alpha \cos \beta - \cos \alpha \sin \beta \end{array}

We then have

H_\varphi Q_\theta = \begin{bmatrix} \cos 2\varphi \cos \theta + \sin 2\varphi \sin \theta&\sin 2\varphi \cos \theta - \cos 2\varphi \sin \theta \\ \sin 2\varphi \cos \theta - \cos 2\varphi \sin \theta&-(\cos 2\varphi \cos \theta + \sin 2\varphi \sin \theta) \end{bmatrix}

= \begin{bmatrix} \cos (2\varphi - \theta)&\sin (2\varphi - \theta) \\ \sin (2\varphi - \theta)&-\cos (2\varphi - \theta) \end{bmatrix} = H_{\varphi-\frac{1}{2}\theta}

We have therefore proved what we set out to prove, that H_\varphi Q_\theta = H_{\varphi-\frac{1}{2}\theta} so that the effect of applying a rotation of angle \theta followed by a reflection through the \varphi-line is equivalent to a reflection through the (\varphi - \frac{1}{2}\theta)-line.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

A reflection followed by a reflection is a rotation

In preparation for answering exercise 2.6.3 in Gilbert Strang’s Linear Algebra and Its Applications, Third Edition, I wanted to derive in detail the effect of a reflection followed by a reflection, a reflection followed by a rotation, and a rotation followed by a reflection. This post demonstrates that a reflection followed by a reflection is equivalent to a rotation.

Assume that we have a matrix that reflects vectors in the line through the origin with angle \theta (the \theta-line) and a second matrix that reflects vectors in the line through the origin with angle \varphi (the \varphi-line). What is the effect of applying both matrices in succession?

One way to gain an intuition about the problem is to play with a cut-out paper triangle on a piece of paper on which you’ve drawn the two lines of reflection. (Or, if your visualization skills are strong, you can imagine doing this.) After trying this you should find that two reflections will apparently cause the triangle to be rotated from its original position.

If this is indeed the case then the effect of successive reflections in the \theta-line and the \varphi-line can be represented by a matrix

Q_\omega = \begin{bmatrix} \cos \omega&-\sin \omega \\ \sin \omega&\cos \omega \end{bmatrix}

for some angle of rotation \omega.

How does the angle \omega relate to the angles \theta and \varphi? Since we are dealing with linear transformations the simplest assumption is that \omega = a\theta + b\varphi for some a and b where a and b are the same for all \theta and \varphi.

To determine the values of a and b let’s look at the unit vector (1, 0) and reflect it in two lines. In the first case we reflect the vector in the 45^{\circ}-line (the line for which y = x) and then in the 90^{\circ}-line (the y-axis). The first reflection takes (1,0) to (0,1) and the second reflection leaves it unchanged. The corresponding angle of rotation is  90^{\circ}.

In the second case we reflect vector (1,0) in the 45^{\circ}-line and then in the 135^{\circ}-line (the line for which y = -x). The first reflection takes (1,0) to (0,1) and the second reflection takes (0,1) to (-1,0). The corresponding angle of rotation is  180^{\circ}.

If the angle of rotation \omega = a\theta + b\varphi then in the first case we would have 90 = 45a + 90b and in the second case we would have 180 = 45a + 135b. Subtracting the first equation from the second we have 90 = 45b or b = 2. Substituting the value of b into the first equation we have 90 = 45a + 180 or a = -2.

Our hypothesis is therefore that doing two reflections in succession in the \theta-line and then the \varphi-line would produce a rotation through the angle \omega = -2\theta + 2\varphi = 2(\varphi - \theta). If this is the case then the matrix representing the rotation would be

Q_{2(\varphi - \theta)} = \begin{bmatrix} \cos 2(\varphi - \theta)&-\sin 2(\varphi-\theta) \\ \sin 2(\varphi-\theta)&\cos 2(\varphi-\theta) \end{bmatrix}

and this matrix should be equal to the product of the matrices corresponding to the two reflections

H_\varphi H_\theta = \begin{bmatrix} 2\cos^2 \varphi - 1&2\cos\varphi\sin\varphi \\ 2\cos\varphi\sin\varphi&2\sin^2 \varphi - 1 \end{bmatrix} \begin{bmatrix} 2\cos^2 \theta - 1&2\cos\theta\sin\theta \\ 2\cos\theta\sin\theta&2\sin^2 \theta - 1 \end{bmatrix}

Note that the entries of these matrices are expressed in terms of the sine and cosine of \theta and \varphi while in the hypothesized matrix Q_{2(\varphi - \theta)} the entries are expressed in terms of the sine and cosine of an expression containing 2\theta and 2\varphi. As a start toward proving that H_\varphi H_\theta = Q_{2(\varphi - \theta)} it might be useful to re-express H_\varphi and H_\theta in terms of the sine and cosine of 2\theta and 2\varphi as well.

If we look at the trigonometric identities

\begin{array}{rcl} \cos (\theta_1 + \theta_2)&=&\cos \theta_1 \cos \theta_2 - \sin \theta_1 \sin \theta_2 \\ \sin (\theta_1 + \theta_2)&=&\sin \theta_1 \cos \theta_2 + \cos \theta_1 \sin \theta_2 \end{array}

we see that

\begin{array}{rcrcrcl} \cos 2\theta&=&\cos (\theta + \theta)&=&\cos \theta \cos \theta - \sin \theta \sin \theta&=&\cos^2 \theta - \sin^2 \theta \\ \sin 2\theta&=&\sin (\theta + \theta)&=&\sin \theta \cos \theta + \cos \theta \sin \theta&=&2\cos \theta \sin \theta \end{array}

and similarly for \cos 2\varphi and \sin 2\varphi.

Using the second identity we can re-express the product of the two reflection matrices as

H_\varphi H_\theta = \begin{bmatrix} 2\cos^2 \varphi - 1&\sin 2\varphi \\ \sin 2\varphi&2\sin^2 \varphi - 1 \end{bmatrix} \begin{bmatrix} 2\cos^2 \theta - 1&\sin 2\theta \\ \sin 2\theta&2\sin^2 \theta - 1 \end{bmatrix}

What about the other entries still expressed in terms of the sine and cosine of \theta and \varphi? Using the identity \sin^2 \theta + \cos^2 \theta = 1 we see that

2\cos^2 \theta - 1 = 2\cos^2 \theta - (\sin^2 \theta + \cos^2 \theta)

= \cos^2 \theta - \sin^2 \theta = \cos 2\theta

and

2\sin^2 \theta - 1 = 2\sin^2 \theta - (\sin^2 \theta + \cos^2 \theta)

= \sin^2 \theta - \cos^2 \theta = -(\cos^2 \theta - \sin^2 \theta) = -\cos 2\theta

This allows us to re-express the product of the two reflection matrices as

H_\varphi H_\theta = \begin{bmatrix} \cos 2\varphi&\sin 2\varphi \\ \sin 2\varphi&-\cos 2\varphi \end{bmatrix} \begin{bmatrix} \cos 2\theta&\sin 2\theta \\ \sin 2\theta&-\cos 2\theta \end{bmatrix}

= \begin{bmatrix} \cos 2\varphi \cos 2\theta + \sin 2\varphi \sin 2\theta&\cos 2\varphi \sin 2\theta - \sin 2\varphi \cos 2\theta \\ \sin 2\varphi \cos 2\theta - \cos 2\varphi \sin 2\theta&\sin 2\varphi \sin 2\theta + \cos 2\varphi \cos 2\theta \end{bmatrix}

We can further simplify this using the trigonometric identities

\begin{array}{rcl} \cos (\theta_1 - \theta_2)&=&\cos \theta_1 \cos \theta_2 + \sin \theta_1 \sin \theta_2 \\ \sin (\theta_1 - \theta_2)&=&\sin \theta_1 \cos \theta_2 - \cos \theta_1 \sin \theta_2 \end{array}

(Note that these follow from the original identities above and the fact that \cos (-\theta_2) = \cos \theta_2 and \sin (-\theta_2) = -\sin \theta_2.)

We then have

H_\varphi H_\theta = \begin{bmatrix} \cos 2\varphi \cos 2\theta + \sin 2\varphi \sin 2\theta&-(\sin 2\varphi \cos 2\theta - \cos 2\varphi \sin 2\theta) \\ \sin 2\varphi \cos 2\theta - \cos 2\varphi \sin 2\theta&\cos 2\varphi \cos 2\theta + \sin 2\varphi \sin 2\theta \end{bmatrix}

= \begin{bmatrix} \cos (2\varphi - 2\theta)&-\sin (2\varphi - 2\theta) \\ \sin (2\varphi - 2\theta)&\cos (2\varphi - 2\theta) \end{bmatrix}

= \begin{bmatrix} \cos 2(\varphi - \theta)&-\sin 2(\varphi-\theta) \\ \sin 2(\varphi-\theta)&\cos 2(\varphi-\theta) \end{bmatrix} = Q_{2(\varphi-\theta})

We have therefore proved what we set out to prove, that H_\varphi H_\theta = Q_{2(\varphi-\theta)} so that the effect of applying a reflection through the \theta-line followed by a second reflection through the \varphi-line is equivalent to a rotation through the angle 2(\varphi - \theta).

Note that if we instead first reflect through the \varphi-line and then through the \theta-line then this is equivalent to rotating through the angle 2(\theta-\varphi) instead of through the angle 2(\varphi-\theta).  We therefore have H_\varphi H_\theta \ne H_\theta H_\varphi except in the cases where \varphi = \theta or (more generally) the two angles differ by a multiple of 360^{\circ}. (The general case is because for any angle \omega we have \sin \omega = \sin (\omega + 360^{\circ}) and likewise for the cosine.) In that case H_\varphi H_\theta = H_\theta H_\theta = I and the equivalent rotation matrix is Q_{2(\varphi-\theta)} = Q_{2(\theta-\theta)} =Q_0 corresponding to rotation through the zero angle.

For example, above we took the unit vector (1, 0) and reflected it in the 45^{\circ}-line (the line for which y = x) and then in the 90^{\circ}-line (the y-axis). The first reflection takes (1,0) to (0,1) and the second reflection leaves it unchanged. The corresponding angle of rotation is  90^{\circ} = 2 \cdot (90^{\circ}-45^{\circ}). If instead we take (1, 0) and reflect it first in the 90^{\circ}-line and then in the 45^{\circ}-line then this takes (1,0) to (-1,0) and then to (0,-1). The corresponding angle of rotation is  -90^{\circ} = 2 \cdot (45^{\circ}-90^{\circ}).

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment

A rotation followed by a rotation is a rotation

In preparation for answering exercise 2.6.3 in Gilbert Strang’s Linear Algebra and Its Applications, Third Edition, I wanted to derive in detail the effect of a reflection followed by a reflection, a reflection followed by a rotation, and a rotation followed by a reflection. For completeness this post recapitulates in a little more detail the argument in section 2.6 that a rotation followed by a rotation is a rotation.

Assume that we have a matrix that rotates vectors through the angle \theta and a second matrix that rotates vectors through the angle \varphi. Intuitively we’d conclude that the effect of applying both matrices in succession is to rotate vectors through the angle \theta+\varphi. Let’s prove this conjecture.

The first rotation is represented by the matrix

Q_\theta = \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix}

and the second rotation is represented by the matrix

Q_\varphi = \begin{bmatrix} \cos \varphi&-\sin \varphi \\ \sin \varphi&\cos \varphi \end{bmatrix}

The effect of the two rotations is thus represented by the product of the matrices:

\begin{bmatrix} \cos \varphi&-\sin \varphi \\ \sin \varphi&\cos \varphi \end{bmatrix} \begin{bmatrix} \cos \theta&-\sin \theta \\ \sin \theta&\cos \theta \end{bmatrix}

= \begin{bmatrix} \cos \varphi \cos \theta - \sin \varphi \sin \theta&-\cos \varphi \sin \theta - \sin \varphi \cos \theta \\ \sin \varphi \cos \theta + \cos \varphi \sin \theta&-\sin \varphi \sin \theta + \cos \varphi \cos \theta \end{bmatrix}

= \begin{bmatrix} \cos \varphi \cos \theta - \sin \varphi \sin \theta&-(\sin \varphi \cos \theta + \cos \varphi \sin \theta) \\ \sin \varphi \cos \theta + \cos \varphi \sin \theta&\cos \varphi \cos \theta - \sin \varphi \sin \theta \end{bmatrix}

Given the trigonometric identities

\begin{array}{rcl} \cos (\varphi + \theta)&=&\cos \varphi \cos \theta - \sin \varphi \sin \theta \\ \sin (\varphi + \theta)&=&\sin \varphi \cos \theta + \cos \varphi \sin \theta \end{array}

we have

\begin{bmatrix} \cos \varphi \cos \theta - \sin \varphi \sin \theta&-(\sin \varphi \cos \theta + \cos \varphi \sin \theta) \\ \sin \varphi \cos \theta + \cos \varphi \sin \theta&\cos \varphi \cos \theta - \sin \varphi \sin \theta \end{bmatrix}

= \begin{bmatrix} \cos (\varphi + \theta)&-\sin (\varphi + \theta) \\ \sin (\varphi + \theta)&\cos (\varphi + \theta) \end{bmatrix}

But this matrix represents Q_{\varphi+\theta}, the rotation of all vectors in the x-y plane through the angle \varphi+\theta. We therefore have Q_\varphi Q_\theta = Q_{\varphi+\theta}.

Note that if we first rotate through the angle \varphi and then through the angle \theta this is equivalent to rotating through the angle \theta and then through the angle \varphi. We therefore have Q_\theta Q_\varphi = Q_\varphi Q_\theta.

NOTE: This continues a series of posts containing worked out exercises from the (out of print) book Linear Algebra and Its Applications, Third Edition by Gilbert Strang.

If you find these posts useful I encourage you to also check out the more current Linear Algebra and Its Applications, Fourth Edition, Dr Strang’s introductory textbook Introduction to Linear Algebra, Fourth Edition and the accompanying free online course, and Dr Strang’s other books.

 Buy me a snack to sponsor more posts like this!

Posted in linear algebra | Leave a comment