TITLE: Projective spaces as affine varieties
QUESTION [11 upvotes]: 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...

REPLY [8 votes]: The fundamental problem seems to be the confusion between the notions of "real algebraic variety" and "algebraic variety over the reals".  Given the similarity in words, it is easy to make this mistake.
You can find a discussion of the distinction in chapter 2 of Coste's lecture notes on real algebraic sets.  Both objects are topological spaces with sheaves of commutative rings, but the former is made by gluing algebraic subsets of $\mathbb{R}^n$, while the latter is made by gluing prime spectra of finite type commutative rings over $\mathbb{R}$.
There is a functor that sends an algebraic variety $X/\mathbb{R}$ to the real algebraic set $X^{ras}$ whose points are the real points of $X$.  Your example demonstrates that this functor does not reflect the property of being affine (i.e., if $X^{ras}$ is affine, $X$ is not necessarily affine).  Neither sheaves of regular functions nor the topological space are preserved by this functor, so you can't reasonably expect global functions to be preserved.
As it happens, there is a more general statement, also mentioned in Coste's lecture notes:

All quasi-projective real algebraic varieties are affine.

In particular, for any quasi-projective variety $Y/\mathbb{R}$, there exists an affine variety $X/\mathbb{R}$, such that $X^{ras} \cong Y^{ras}$.