Why is a locally compact Hausdorff space $X$ compact iff $C_0(X)$ is unital? I apologise if this question is trivial. I don't know much about $C^*$-algebras and am learning the basics of the theory from I.F. Putnam's online notes Lecture Notes on $C^*$-Algebras.
Let $X$ be a locally compact Hausdorff space. In the linked notes, $C_0(X)$ is defined to consist of the continuous maps $f:X\to\mathbb{C}$ that vanish at infinity i.e. for which $$\{x\in X:|f(x)|\geq\epsilon\}$$ is a compact subset of $X$ for each $\epsilon>0$. Why must it be the case that $C_0(X)$ is unital iff $X$ is compact?
First of all, if we look at $C(X)$ (the algebra of continuous functions $f:X\to\mathbb{C})$, then the identity is the constant function $x\mapsto 1$, correct?
My intuition is telling me that this function would fail to be continuous if $X$ is non-compact. I don't know, I might be totally wrong. If someone could explain this, that would be great.
 A: The constant function 1 is continuous no matter what  $X$ is.  This is extremely easy to prove from the basic definition of "continuous".
The problem is in the phrase "vanishes at infinity".  If you study the definition of this term carefully, you should be able to prove that the constant function 1 vanishes at infinity if, and only if, $X$ is compact.  Hence when $X$ is not compact, $1$ is not an element of $C_0(X)$.
You can then go on to show that if $C_0(X)$ does have a unit, it must be the constant function 1.  So $C_0(X)$ is unital if and only if $X$ is compact.
A: The function $1_X: X \to \Bbb C$ is in fact the multiplicative identity in $C(X)$.
If $X$ is compact, then clearly the function $1_X: x \to \Bbb C$ which takes every $x \in X$ to $1 \in \Bbb C$, i.e. $1_X(x) = 1$, $\forall x \in X$, has compact support, i.e., $1_X \in C_0(X)$.
Now if $1_X \in C_0(X)$, then by a careful reading of the definition of $C_0(X)$ presented in Example 1.2.4 of the linked notes, we see that for any real $\epsilon > 0$, there is a compact subset $K \subset X$ such that $\vert 1_X(x) \vert < \epsilon$ for $x \in X \setminus K$; but for any $\epsilon < 1$ there can be no such $x$, that is, $X \setminus K = \emptyset$; thus $X = K$ is compact.
QED.
