Proving the Linearity of the Orthogonal Projection function 
Projection of a vector $x$ on a given vector $y$. Let $y$ be a given $n$-vector, and consider $f:\mathbb R^n\to\mathbb R^n$, defined as 
  $$
f(x)=\frac{x^Ty}{\|y\|^2}\,y.
$$
  We know, from a previous exercise, that $f(x)$ is the projection of $x$ on the (fixed, given) vector $y$. 
Is $f$ a linear function of $x$? If your answer is yes, given an $n\times n$ matrix $A$ such that $f(x)=Ax$. If your answer is no, show with an example that $f$ does not satisfy the definition of linearity $f(\alpha x+\beta y)=\alpha f(x)+\beta f(y)$. 

The exercise mentioned above proves that the existence of the orthogonal projection function. However, I am not sure whether there exists a matrix A that fits the linearity definition.
 A: One can check that $f$ is linear from the fact that the transpose is linear. But another way to do it is to find $A$ directly. 
The key fact is that, in $\mathbb R^n$, $x^Ty=y^Tx$. Then
$$
f(x)=\frac{x^Ty}{\|y\|^2}\,y=\frac{y^Tx}{\|y\|^2}\,y=y\frac{y^Tx}{\|y\|^2}
=\frac{yy^T}{\|y\|^2}\,x
$$
(the commutation works because $y^Tx/\|y\|^2$ is a scalar). 
So $A$ exists and it is equal to $\displaystyle\frac{yy^T}{\|y\|^2}$. 
A: As almost always with linear maps, you can easily recognise the fact that it is linear from that fact that its definition is made up of linear steps. Here you can see three successive steps that take you successively $\def\R{\Bbb R}\R^n\to\R\to\R\to\R^n$: (1) from $x$ compute the scalar product $x^Ty$ with $y$, (2) divide that scalar by the nonzero constant $\|y\|^2$, and finally (3) scalar-multiply the vector $y$ by the resulting scalar. Each of the steps is a well known example of a linear map, so their composition is linear as well.
To find the matrix, just multiply the matrices of the linear steps, from right to left. That gives your the matrix product $y\cdot(\frac1{\|y\|^2})\cdot y^T$ (the matrices are, from left to right, of sizes $n\times 1$, $1\times1$, and  $1\times n$).
