This works over the reals but not over the complex field. Consider the set of all $n\times n$ matrices $A$
such that
1. $A^2=A$
2.$A^T=A$
3. $\mathrm{Trace}(A)=1$


The first condition makes $A$ a projection to a subspace of $\mathbb{R}^n$. The second ensures that $A$ is *diagonalizable* so its eigenvalues are all 0 or 1.The third guarantees that the image of the projection is one-dimensional. Such matrices are in a 1-1 correspondence with one-dimensional subspaces and so constitute $\mathbb{R}P^{n-1}$. 


This seems to represent real projective spaces as affine varieties, with plenty of induced nonzero regular functions. How do we reconcile this with the fact that projective spaces have only constant regular functions?


This does not work over the complexes since $A$ would have to equal its conjugate transpose (to be guaranteed diagonalizable) and conjugation is not algebraic.


This is puzzling me to no end...



Projective spaces as affine varieties
The theorem that projective spaces are not affine varieties is a theorem over the complex numbers. As you note, your construction fails over the complex numbers, so there is no contradiction.


To give an even simpler example over the reals, $\mathbb {RP}^1=S^1$ is the vanishing set of $x^2+y^2-1=0$.


I think you're slightly confused about what the functions of your conditions are. Every matrix satisfying condition $1$ is diagonalizable. Indeed, all matrices satisfying a polynomial equation without repeated roots are diagonalizable, and $A^2-A=0$ certainly has no repeated roots. The second condition ensures that the kernel is the orthogonal complement of the image, which is the only way to ensure that there is a unique projection with a given image. Remove it, and you have an affine bundle on $\mathbb P^n$, which is of course perfectly alright.


If you take $AA^T=0$ to not be the conjugate-transpose in the complex case, then you get an affine subvariety of $\mathbb P^n$ - the complement of the hypersurface of points corresponding to lines where a certain bilinear form on $\mathbb C^{n+1}$ is nonzero, that is, the vanisihing set of a degree two polynomial equation.


