Is there a known example of a ring endomorphism $f: \mathbb{Z}[x\_1, \ldots, x\_n] \to \mathbb{Z}[x\_1, \ldots, x\_n]$ such that $f \circ f = f$ but whose image is not isomorphic to a polynomial ring? 


My own interest in this has to do with better understanding the (categorical) Cauchy completions of Lawvere theories for some familiar types of algebraic objects; here we are dealing with the Lawvere theory of commutative rings. But apparently this *type* of problem is of interest to algebraists in the context of hard problems like the Jacobian conjecture and the cancellation problem, so there is a certain body of work out there already on related material. 


From the literature I've scanned so far (articles by Costa, Shpilrain, Picavet, Gupta, and others), a lot of attention is paid to retracts of polynomial algebras over *fields*, but I'm having quite a hard time finding a clear statement for the case of polynomial algebras over $\mathbb{Z}$. One tantalizing lead was a statement by Picavet [here](http://math.univ-bpclermont.fr/~picavet/archives/2002-30.pdf): "We were motivated by an unsolved conjecture: a projective algebra of finite type over a field $A$ is a polynomial ring. An example by Costa shows that the statement is false if $A$ is not a field." I couldn't find a statement by Costa which treated every non-field $A$ (including $\mathbb{Z}$ in particular); I suspect Picavet meant that there *exist* non-fields $A$ for which the statement is false. An interesting example of such $A$ can be extracted from Gupta's later negative solution to the cancellation problem, as mentioned by Jeremy Rickard [here](https://mathoverflow.net/a/208507/2926) at the MO discussion [Is a retract of a free object free?](https://mathoverflow.net/questions/90734/is-a-retract-of-a-free-object-free). (Actually, Gupta's constructions more significantly show that the statement is false for any field of positive characteristic, but this work can be used to derive some non-field examples as well.) 


Akhil Mathew asked essentially the same question at Math.SE [here](https://math.stackexchange.com/questions/98210/are-projective-rings-over-mathbbz-free), and got pointers to literature from Mariano Suárez-Alvarez, but I'm hoping to get something more definitive now.



What are retracts of polynomial rings?
Existence of such an example follows from the same result of Asanuma that is crucial for Gupta's work, see the article 


Teruo Asanuma, "Polynomial fibre rings of algebras over noetherian rings", Inventiones mathematicae 87 (1987), 101–127 ([DOI link](https://doi.org/10.1007/BF01389155)). 


It follows from Corollary 5.3 of that article that if  

$$
A=\mathbb{Z}[x,y,z]/(-x^{p^e}+y+y^{sp}+pz),
 $$
where $p$ is a prime number and $e,s$ are positive integers such that $p^e\not\mid sp$, $sp\not\mid p^e$, then $A$ is not isomorphic to a polynomial ring, but $B=A[t]$ is isomorphic to a polynomial ring in three variables. Of course, $A$ is a retract of $B$ via the evaluation at $t=0$.


EDIT:
Moreover, consider 
 $$
A\_n:=\mathbb{Z}[x,y,z,x\_1,\ldots,x\_n]/(-x^{p^e}+y+y^{sp}+px\_1\cdots x\_nz),
 $$
then the proof of the same Corollary 5.3 (in the case $R=\mathbb{Z}[x\_1,\ldots,x\_n]$) can be adapted to show that $A\_n[t]$ is isomorphic to the polynomial ring in $n+3$ variables, but $A\_n$ is not isomorphic to the polynomial ring in $n+2$ variables. 


