Vector $W$ gives the distribution of A's, B's, C's, D's, and E's in a particular Kryptonian plaintext message, respectively. The other three vectors give the probability distributions of these letters (in the same order) for messages encoded with simple shift of 1, 2, or 3 letters, respectively. Which of the three probability vectors most closely matches $W$? (To be more precise, in terms of vectors, the one that most closely matches $W$ will form the smallest angle with $W$.)

$$\begin{array}{c} W=(0.35, 0.3, 0.1, 0.05, 0.2)\\\\ P_1 = (0.35, 0.05, 0.1, 0.2, 0.3)\\ P_2 = (0.3, 0.35, 0.05, 0.1, 0.2)\\ P_3 = (0.2, 0.3, 0.35, 0.05, 0.1) \end{array}$$

Since vectors $P_1, P_2,$ and $P_3$ contain the exact same values, just in a different order, they all have the same magnitude.

Recall that the cosine of the angle between two vectors $x$ and $y$ is given by $$\cos \theta = \frac{x \cdot y}{|x||y|} \quad \textrm{ where } |v| \textrm{ is the magnitude of vector } v$$

This means that the vector that most closely matches $W$ (in the sense that the angle between $W$ and this vector is minimized) will have the largest dot product with $W$.

So, we compute the three dot products:

$$\begin{array}{rcl} W \cdot P_1 &=& (0.35)(0.35)+(0.3)(0.05)+(0.1)(0.1)+(0.05)(0.2)+(0.2)(0.3) = 0.2175\\ W \cdot P_2 &=& (0.35)(0.3)+(0.3)(0.35)+(0.1)(0.05)+(0.05)(0.1)+(0.2)(0.2) = 0.2555\\ W \cdot P_3 &=& (0.35)(0.2)+(0.3)(0.3)+(0.1)(0.35)+(0.05)(0.05)+(0.2)(0.1) = 0.2175 \end{array}$$

Thus $P_2$ most closely matches $W$.