### Instruction: Let $P$ be the plane passing through the origin with normal vector $\begin{pmatrix} 1 \\ -2 \\ 1 \end{pmatrix}.$  Find the matrix $\mathbf{P}$ such that for any vector $\mathbf{v},$ $\mathbf{P} \mathbf{v}$ is the projection of $\mathbf{v}$ onto plane $P.$.### Response: To project a vector $\mathbf{v}$ onto a plane, I need to subtract the component of $\mathbf{v}$ that is parallel to the normal vector of the plane.
This means that $\mathbf{P} \mathbf{v}$ should be equal to $\mathbf{v} - \frac{\mathbf{v} \cdot \mathbf{n}}{\mathbf{n} \cdot \mathbf{n}} \mathbf{n},$ where $\mathbf{n}$ is the normal vector of the plane.
So, to find $\mathbf{P},$ I need to find a matrix that satisfies this equation for any $\mathbf{v}.$
I notice that $\frac{\mathbf{v} \cdot \mathbf{n}}{\mathbf{n} \cdot \mathbf{n}}$ is a scalar, so I can rewrite the equation as $\mathbf{P} \mathbf{v} = \mathbf{v} - \mathbf{n} (\mathbf{n}^T \mathbf{v}) / (\mathbf{n}^T \mathbf{n}).$
Now, I see that $\mathbf{n} (\mathbf{n}^T \mathbf{v}) / (\mathbf{n}^T \mathbf{n})$ is a matrix-vector product, so I can write it as $\mathbf{Q} \mathbf{v}$ for some matrix $\mathbf{Q}.$
This means that $\mathbf{P} \mathbf{v} = \mathbf{v} - \mathbf{Q} \mathbf{v} = (\mathbf{I} - \mathbf{Q}) \mathbf{v},$ where $\mathbf{I}$ is the identity matrix.
So, $\mathbf{P} = \mathbf{I} - \mathbf{Q}.$
Now, I need to find $\mathbf{Q}.$
I see that $\mathbf{Q}$ is just the matrix that maps any vector to its component along $\mathbf{n}.$
To find $\mathbf{Q},$ I can use the outer product of $\mathbf{n}$ with itself, and divide by the magnitude of $\mathbf{n}$ squared.
That is, $\mathbf{Q} = \frac{\mathbf{n} \mathbf{n}^T}{\mathbf{n}^T \mathbf{n}}.$
I can compute $\mathbf{n}^T \mathbf{n} = 1^2 + (-2)^2 + 1^2 = 6.$
I can also compute $\mathbf{n} \mathbf{n}^T = \begin{pmatrix} 1 \\ -2 \\ 1 \end{pmatrix} \begin{pmatrix} 1 & -2 & 1 \end{pmatrix} = \begin{pmatrix} 1 & -2 & 1 \\ -2 & 4 & -2 \\ 1 & -2 & 1 \end{pmatrix}.$
So, $\mathbf{Q} = \frac{1}{6} \begin{pmatrix} 1 & -2 & 1 \\ -2 & 4 & -2 \\ 1 & -2 & 1 \end{pmatrix}.$
Finally, I can find $\mathbf{P} = \mathbf{I} - \mathbf{Q} = \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} - \frac{1}{6} \begin{pmatrix} 1 & -2 & 1 \\ -2 & 4 & -2 \\ 1 & -2 & 1 \end{pmatrix} = \frac{1}{6} \begin{pmatrix} 5 & 2 & -1 \\ 2 & 2 & 2 \\ -1 & 2 & 5 \end{pmatrix}.$