Spivak – Rotating Points Problem

So I decided to do a problem from my copy of Michael Spivak’s Calculus; after a bit of looking, I decided on Problem 1 of Appendix 4 – Vectors. It talks about rotating points (really vectors) on a grid, and how to compute the resulting point if you rotate it by some angle θ.

Keep in mind that I’m not using the latest edition; I’m using the 3rd Edition, and the problem can be found on p. 77.


Let’s jump into it!

The definitions:

    The function \(R_\theta(v)\) applies a rotation of angle \(\theta\) to a point (vector) \(v\). Here’s a picture to illustrate just what I meant by that rather confusing statement:
Helpful Picture

We take that purple point \(v\) and rotate it by some angle \(\theta\) to get \(R_\theta(v)\).

The Problem

The statement is rather simple…

Given \(  \theta \) and a point \(v\), can you find a simple form of \(R_\theta(v)\), which does not require a lot of calculations?

I’ll post the solution below…

The Solution

The road map

I’ll explain the ‘road map’ on how to tackle the problem – then we can start tackling it and sorting out the details along the way! Here’s how we’re going to do it:

  1.  Solve the ‘trivial’ cases, for \( v = (0, 1)\) and \((1, 0)\), respectively. They’ll come in later!
  2. Prove that \(R_\theta(u + w) = R_\theta(u) + R_\theta(w)\)
  3. Prove that \(R_\theta(a \cdot u) = a  \cdot R_\theta(u)\)
  4. Since that any vector \(v\) can be expressed as some combination of \((0, 1)\) and \((1, 0)\) and their multiples, and since that we’ve proved the mechanics along the way, we can put it all together into the closed form of \(R_\theta(v)\)
The Solution

First of all, let’s treat the easy cases:

\( v = (0, 1)\) and \((1, 0)\)

The case for (0, 1). It’s just a rotation for the other case.

Some elementary trigonometry comes into play here; nothing too special.

When you rotate the points \((0, 1)\) with any angle, the result will be \((-sin\theta, cos\theta)\); when you rotate \((1,  0)\) by an angle, the result will be \((cos\theta, sin \theta)\).

That’s the easy cases down, now we’ll prove that

Lemma 1: $$R_\theta(u + w) = R_\theta(u) + R_\theta(w)$$.


Let \(u, w\) be vectors, and assume that the angle formed by the vectors with the \(x\) axis are \( \theta_1 \) and \( \theta_2 \), respectively. Then, the angle that the sum of the vectors makes with the \(x\) axis is \(\frac{\theta_1 + \theta_2}{2}\), which is also the average of the two angles, as shown:

So, if we rotate \( w + u \) by some angle \( \theta \), then the length of \( w + u \) won’t change a bit; it’s clearly the angle of the vector that changes! The angle of the vector goes from \(\frac{\theta_1 + \theta_2}{2}\) to the even more scary looking, \(\frac{\theta_1 + \theta_2}{2} + \theta\). The first part in the fraction is just the angle we already had, and the newly added \( \theta \) is the new addition here. Therefore, \( R_{\theta})(w + u)\) has an angle of \(\frac{\theta_1 + \theta_2}{2} + \theta\). All we need to do is to prove that, if you apply \(R_{\theta}\) first to \(w\) and \(u\), then sum then, then the result will be equal to the above result, by comparing their absolute values and the angle, because if their angles are the same, and so are their absolute values, then they have the same polar co-ordinate, and therefore are the same vector. Let’s go.

Now, consider the two vectors, \( R_{\theta}(w)\) and \( R_{\theta}(u)\). They have the same absolute value as the original vectors, since rotating a point by an angle does not change its absolute value (think a unit circle with fixed radius), so \( \left| R_{\theta}(w) + R_{\theta}(u) \right| = \left| w + u \right|  \). Now, the angle of \(R_{\theta}(w) + R_{\theta}(u)\) is the average of their angles, which is \(  \frac{(\theta_1 + \theta) + (\theta_2+ \theta) }{2} = \frac{\theta_1 + \theta_2}{2} + \theta \)


Doesn’t that just look familiar? Why, yes! That’s the same angle as the previous vector,  \(R_{\theta})(w + u)\)! Therefore, we can confidently say that, since

$$ \left| R_{\theta}(w) + R_{\theta}(u) \right| = \left| w + u \right|  $$


$$ Angle_{R_\theta(u + w)} = Angle_{R_\theta(w) + R_\theta(w)} $$,


$$ R_\theta(u + w) = R_\theta(w) + R_\theta(w) $$.

We’re halfway through the proof! This part was the longest part, and congratulations on those who make it through!

The second Lemma:

$$R_{\theta}(a \cdot w) = a \cdot R_{\theta}( w), a \in \mathbb{R}$$


This one isn’t much different than the last proof: prove that the absolute values of \( R_{\theta}(a \cdot w) \) and \(a \cdot R_{\theta}( w)\) are the same, and then prove that their angles are the same. First, the absolute values. Rotating a point by some angle does not change its length (absolute value), so \( \left|R_{\theta}(a \cdot w)\right|  = \left|a \cdot w\right| \), and \( \left| a \cdot R_{\theta}( w) \right| =  \left|a \cdot w\right| \). That’s the absolute value fixed, what about the angle? Well, stretching a vector by some scalar doesn’t affect its angle, and therefore \(Angle_{R_{\theta}(a \cdot w)} = Angle_{R_{\theta}(w)}\), and \( Angle_{a \cdot R_{\theta}(w)} = Angle_{R_{\theta}(w)}\), and that completes the proof of the lemma. Here’s the second Lemma in its full glory:

Lemma 2: $$ R_{\theta}(a \cdot w) = a \cdot R_{\theta}( w), a \in \mathbb{R} $$

The Epic Finale

Ooh! Here’s the fun part! Notice first that any 2-D vector \(w\) can be written as a set of two points \( (x, y) \), with \(x, y \in \mathbb{R}\). Specifically, it can be written as \( w  = x \cdot \left ( 1, 0 \right ) + y \cdot \left ( 0, 1 \right ) \). Apply the \(R_{\theta}(w)\) function to that, and you get this thing: \(R_{\theta}(w) = R_{\theta}(x \cdot (1, 0) + y \cdot (0, 1))\). By Lemma 1, \(R{\theta}(x \cdot (1, 0) + y \cdot (0, 1)) = R_{\theta}(x \cdot (0, 1)) + R_{\theta}(y \cdot (1, 0))\). And by Lemma 2, these two terms can be split further, since \(x\) and \(y\) are scalars. By Lemma 2,

\( R_{\theta}(x \cdot (0, 1)) + R_{\theta}(y \cdot (1, 0)) = x \cdot R_\theta((1, 0)) + y \cdot R_\theta((0, 1)) \).

Ooh, what’s this? Our old friends, \( R_\theta((1, 0)) \) and \(R_\theta((0, 1))\)? Directly substituting in \(\begin{cases} R_\theta((0, 1)) = (-\sin\theta, \cos \theta)
R_\theta((1, 0)) = (\cos\theta, \sin \theta) \end{cases}\), we obtain,

\(\begin{align*}R_{\theta}(x \cdot (1, 0)) + R_{\theta}(y \cdot (0, 1)) = x \cdot (\cos\theta, \sin \theta)+ y \cdot (-\sin\theta, \cos \theta) \\ = x \cos \theta + x \sin \theta – y \sin \theta + y \cos \theta\\ = (x \cos \theta – y \sin \theta, x \sin \theta + y \cos \theta)\end{align*}\)

, and that completes the proof. Here’s the full thing:

If a vector \( w \) can be given in co-ordinates as \( (x, y) \), then I can apply a rotation of angle \( \theta \) on it, and find its new co-ordinates, which is given by the formula \( (x \cos \theta – y \sin \theta, x \sin \theta + y \cos \theta) \).


I hear some (a few? A little? None?) of you say, “What can this be even used for?” Well, one thing I came up with is the proof of the trigonometric identity, \( cos(\theta + \phi) = \cos \theta \cos \phi + \sin \phi \sin \theta [latex]. Given the point [latex](\cos \theta, \sin \theta)[latex], we wish to add an angle, [latex] \phi \) to it, and find its co-ordinates, given by

$$ R_{\phi}(\cos \theta, \sin \theta) = (\cos \theta \cdot \cos \phi – \sin\theta\cdot\sin\phi, \cos\theta\sin\phi + \sin\theta \cdot \cos\phi)$$.

The \(x\) co-ordinate of this new point is \(\cos \theta \cdot \cos \phi – \sin\theta\cdot\sin\phi\), and its radius one, so we obtain,

$$cos(\theta + $$phi) = \frac{\cos \theta \cdot \cos \phi – \sin\theta\cdot\sin\phi}{1} = sin(\theta + \phi) = \frac{\cos\theta\sin\phi + \sin\theta \cdot \cos\phi}{1} = \cos\theta\sin\phi + \sin\theta \cdot \cos\phi$$, and also,

$$sin(\theta + \phi) = \frac{\cos\theta\sin\phi + \sin\theta \cdot \cos\phi}{1} = \cos\theta\sin\phi + \sin\theta \cdot \cos\phi$$

,which is correct.

Train Station Math

Hey all!



The new Cambridge North train station

A video by great Youtuber Mathematician James Grime (aka singingbanana) recently posted a video on a new train station in Cambridge, with some very interesting patterns on it (above). While not derived from Conway’s Game of Life, it is derived from an automata, dubbed Rule 135 by mathematician Stephen Wolfram. Here’s a link (and the wiki page) if you’re interested. It’s an interesting cellular automata that can be described with a positive integer no greater than \(2^8\), or \(256\). Below is an example.

(example is from Rule 30; picture is from the Wolfram MathWorld page.)

Screenshot from Wolfram Mathworld

So, why the name?

Good question!

Notice that the above number can be written as \(00011110_2\). Convert that to decimal, and you get the number 30. Similarly, if you had rule 255. that just means that you’d have to colour in every grind, regardless; if you had rule 0, you wouldn’t have to colour in any grid at all.

So, to answer your question, it’s simply a matter of ‘Rule 35 sounds better than “Rule 00011110 in base 2″‘.

Now that we’ve got the naming out of the way…

Here’s how it works:

  1. Define a starting position. For example, I could have a row of all blank grids, and one filled in in the middle.
  2. For each grid in the second row, look at the grid directly above it, the grid to the upper-left, and to the upper right. The pattern will decide if the grid we’re looking at is coloured or not. For example: if the grid I was looking at had the grid above it filled in, the grid to the upper-left blank, and the upper-right filled in, then we’d have to find the picture corresponding to that picture (fifth one from the left), and see that the grid ought to be filled in.do this for every grid in the row, then move on to the next row. Rinse and repeat.

    Here’s a little demo that I hacked up in JSBin with canvas: Demo

You can get some really beautiful pictures in this: I’ve used the ruleN.randomise() function, and they look great! Block size was set to 50, iterations to 10.


Rule 95
Rule 30
Rule 27



I think it’s amazing that such a basic rule – turning grids black or white can produce such mesmerizing patterns! What’s more, many of them have very interesting properties! Some of them are logic gates: Rule 90 is a XOR gate, along with Rule 110 being proven a Turing Machine! Imagine trying to run a simple ‘Hello World’ on that! My favourite Rule is probably 90, which has the property of generating a Sierpinski Triangle….  Spoilers! I might make a short article explaining the code, but I think the comments are pretty self-explanatory.


Thanks for reading!