TITLE: extending Zariski closed sets
QUESTION [7 upvotes]: Let $U \hookrightarrow X$  be an embedding of algebraic varieties such that $U$ is dense in $X$. Then any Zariski closed subset of $U$ is a trace of a Zariski closed subset of $X$.
It escapes me why a similar fact is not true for complex manifolds.
Again, let $U \hookrightarrow X$ be an embedding of complex manifolds such that $U$ is dense in $X$ and let $Z$ be an analytic subset of $X$. Then $Z$ is not necessarily an intersection $Z' \cap U$ where  $Z'$ is an analytic subset of $X$. For example, if $X=\mathbb{P}^2$, $U=\mathbb{A}^2$ and $Z$ is the set defined by the equation $y=exp(x)$ then by Chow's theorem it cannot be a trace of an analytic subset of $\mathbb{P}^2$ since all such subsets are algebraic.
What is the reason that makes the extension of an analytic subset fail? Is it possible to formulate a general criterion?

REPLY [7 votes]: The most useful general criterion for extending analytic subsets of an open subset of a manifold  to the whole manifold  is :   
Theorem of Remmert-Stein
Let $X$ be an analytic space (for example  a complex manifold), $Z\subset X$ a closed  analytic subspace  of dimension $\lt n$ and $A\subset U$ a purely  $n$-dimensional closed analytic subset of the open set $U=X\setminus Z\subset X.$
Then the closure $\bar A\subset X$ is an analytic subspace of $X$.  
So the "reason" for the failure of extension in your example is that your $Z$ is too big: it is a line of dimension one and your analytic subset , the graph of the exponential function, has dimension one as well, so that its  closure in $\mathbb P^2 $ is no longer analytic.
However if you delete a point  $Q\in \mathbb P^2 $ then  any analytic curve  $C\subset  \mathbb P^2 \setminus \lbrace Q \rbrace$ will have analytic (even algebraic) closure $\bar C\subset \mathbb P^2$
Edit
In a comment below Dima asks about extending an analytic subset of $A\subset \mathbb A^2(\mathbb C)$ to $\mathbb P^2(\mathbb C)$, a situation where Remmert-Stein's theorem doesn't apply .
By Chow's theorem $\bar A  \subset     \mathbb P^2    $ is analytic iff it is algebraic, and in that case $A\subset \mathbb A^2$ is algebraic too, so that finally $A$ is extendable iff it is algebraic.
The simplest obstruction against algebraicity of $A$ might be that a line in $\mathbb A^2$ not contained in $A$ intersects $A$ only in finitely many points.
In Dima's example where $A$ is defined by $y=exp(x)$ , the line $y=1$ intersects $A$ in infinitely many points, which is an obstruction against $A$ being algebraic and thus explains why $A$ is not extendable to $\mathbb P^2$