# Find projective matrix with given null space

Find an $n \times n$ projective matrix, $P$, such that its null space is spanned by vector $(1,1,...,1)^T$.

My attempt at solution: A projective matrix is a matrix such that $P^2=P$ and $P^T=P$, i.e., it is a symmetric matrix, whose square is itself. Now by rank-nullity theorem, we know that $P$ is supposed to have $(n-1)$ linearly independent columns. So my solution would be the following $n \times n$ matrix $$\begin{pmatrix} 1 & 0 & 0 & 0 & \cdots & 0 & -1\\ 0 & 1 & 0 & 0 & \cdots & 0 & -1\\ &&& \vdots &&&\\ 0 & 0 & 0 & 0 & \cdots & 1 & -1\\ 0 & 0 & 0 & 0 & \cdots & 0 & 0 \end{pmatrix}$$

It easy to see that the null space is indeed given by $(1,1,1,...,1)^T$. On the other hand, $P^2=P$, which satisfies one of the requirements of being a projective matrix. However, I can’t think of any way of making this a symmetric matrix.

Any help would be appreciated.

Since $P^2=P$, you have a perfectly good projection matrix. However, the definition of “projective matrix” that you have also requires that $P^T=P$, which makes it specifically an orthogonal projection. For that, the column space of the matrix must be the orthogonal complement of the null space.
There are several ways that you might construct such a matrix. A somewhat brute-force method is to find a basis $\{v_1,\dots,v_{n-1}\}$ for the orthogonal complement of $W=\operatorname{span}\{(1,1,\dots,1)^T\}$. Assemble these vectors and $w=(1,1,\dots,1)^T$ itself into a matrix $B$. The desired projective matrix is then $$B\begin{bmatrix}I_{n-1}&0\\0&0\end{bmatrix}B^{-1}.$$ (Do you see why?) Note that the non-zero rows of the matrix that you’ve constructed are a basis for $W^\perp$.
A simpler way is to observe that orthogonal projections onto $W$ and $W^\perp$ are complementary in the sense that if $P$ is the orthogonal projection onto $W$, then $I-P$ is the orthogonal projection onto $W^\perp$. Since $W$ is one-dimensional, the orthogonal projection matrix onto this subspace is quite easy to construct: the projection of a vector $v$ onto $w$ is ${w^Tv \over w^Tw}w = {ww^T\over w^Tw}v$, so the projection matrix onto $W^\perp$ is $I-{ww^T\over w^Tw}$. This is clearly symmetric, as required. For the vector in your problem, this will be $I_n-\frac1n\mathbb 1_n$, where $\mathbb 1_n$ is the $n\times n$ matrix of all $1$’s, i.e., $P$ has $(n-1)/n$ down its main diagonal and $-1/n$ elsewhere.
The projection that you are looking for is $Px = x - \frac 1{\|v\|^2}\langle x,v\rangle v$, i.e., $$P = I - \frac{vv^T}{v^Tv},$$ where $v = (1,1,\ldots,1)^T$.