I have some basic question about real analytic sets which I've asked in MSE but couldn't get an answer there.


Let $M$ be a real analytic manifold, and let $X \subset M$ be an analytic set. We know by the definition of an analytic set that for every $x \in X$ there exists an open neighborhood $U$ of $x$ in $M$ and a real analytic function $f : U \to \mathbb{R}$ such that


$$ X \cap U = \left\{ p \in U \mid f(p) = 0 \right\}. $$


So, locally analytic sets are zero sets of real analytic functions. Can this be said globally? That is, can we find an open neighborhood $V$ of $X$ in $M$ and a real analytic $f : V \to \mathbb{R}$ such that $X = \left\{ p \in V \mid f(p) = 0 \right\}$? If that's not always possible, is it possible under the further assumption that $X$ can be expressed as a finite union of analytic sets, each of which is a smooth submanifold of $M$?



Can a real analytic set be expressed as the zero set of a single real analytic function?
Let me expand on my comment. In the terrific book "Topics on real analytic spaces" by Guaraldo, Macri and Tancredi one can find a discussion of such questions. See page 64 & 65 and in particular Theorem 2.1, Definition 2.2 and Remark 2.3. Let me quote Theorem 2.1 and make some remarks.


**Theorem 2.1.** Let $Y$ be a coherent real analytic variety of finite dimension [e.g. a connected real analytic manifold]. For a [real analytic] subvariety $X$ of $Y$ the following statements are equivalent.


$i)$ There exist $p$ analytic functions, $f\_1,....,f\_p\in \Gamma(Y,\mathcal{O}\_Y)$, such that $X=\left\{x\in Y \mid f\_1(x)= \dots = f\_p(x)=0\right\}$.


$ii)$ There exists a coherent sheaf of $\mathcal{O}\_Y$-modules $F$ such that $X=\mathrm{supp}F$.


$iii)$ There exists a [coherent] real analytic subspace of $(Y,\mathcal{O}\_Y)$ such that its reduction is $X$.


$iv)$ There exists a closed complex analytic subvariety $\tilde{X}$ of the complexification $\tilde{Y}$ of $Y$ such that $\tilde{X}\cap Y = X$.


Note that the inserted comments marked with [...] were added by me and note that $\mathcal{O}\_Y$ denotes the sheaf of real analytic functions on $Y$. Real analytic subvarieties that satisfy one of these equivalent conditions are often given the name $\mathbb{C}$-analytic or $C$-analytic. This name is in my opinion very misleading and I prefer just saying "$X$ has global defining functions" or "$X$ admits global equations". It should be noted that admitting global equations ***is*** dependent on the embedding and hence it is not an intrinsic aspect on $X$.


In general and as a word of caution, real analytic subsets/subvarieties are quite wild objects and there are many pathological examples. For example, in the mentioned book in example 2.4 on page 65, the authors construct a real analytic subset $X$ in $\mathbb{R}^3$ such that for every real analytic $f\colon U \to \mathbb{R}$ with $f\mid\_X=0$ and $U$ being an open neighbourhood of $X$ in $\mathbb{R}^3$, one has $f=0$. Similar examples were also already known to H. Cartan (see for example the [paper](http://www.numdam.org/item/BSMF_1957__85__77_0/) "Varietes analytiques reelles et varietes analytiques complexes" (1957)). For a "modern" example with some visualizations of the same phenomenon you can also look at this [paper](https://arxiv.org/abs/1412.4838) by Jiri Lebl.


To your second question: Suppose that $Y$ is a real analytic manifold and $X=\bigcup\_{i=1}^k M\_i$, where each $M\_i$ is a real analytic submanifold of $Y$. Real analytic submanifold are, in particular, coherent real analytic subspaces and by Theorem 2.1 have global defining functions. Hence, there exist finitely many $f\_{i,j}$ such that $M\_i$ is equal to the vanishing set of the $f\_{i,j}$, with fixed $i$. As was already mentioned in the comments: In the real analytic situation one can combine finitely many defining functions to one defining function by considering $g\_i:= \sum\_j f\_{i,j}^2$, as $g\_i$ is zero if and only if all the summands are zero. Therefore, all the $M\_i$ have a global defining function $g\_i$. Because $X$ is a union of the $M\_i$ it follows that $h:=\prod\_i g\_i$ is a global defining function of $X$.


