If $\mathop{\mathrm{Spec}}A$ is not connected then there is a nontrivial idempotent

This is most easily solved using the structure sheaf. More generally, let $X$ be any locally ringed space. Then there is a bijection between the clopen subsets of $|X|$ (the underlying space) and the idempotent elements of $\Gamma(X,\mathcal{O}_X)$. Essentially this comes down to the fact that a local ring has only trivial idempotents. Then for idempotents $e$ we have that $D(e)=\{x \in X : e_x=1\}$ is clopen with complement $V(e)=\{x \in X : e_x=0\}$, and conversely if $U \subseteq X$ is clopen then there is a unique idempotent $e$ satisfying $e|_U=1$ and $e|_{U^c}=0$ (by definition of a sheaf).

This bijection implies immediately that $X$ is connected iff $0,1$ are the only idempotents in $\Gamma(X,\mathcal{O}_X)$. And this has really nothing to do with spectra, it also holds for example for the sheaf of smooth functions on a manifold.

EDIT: Since not everyone is familiar with the structure sheaf, here is a more down-to-earth proof. I hope that this motivates to get familiar with the structure sheaf, because it is quite useful and gives geometric intuition.

Lemma: Let $A$ be a commutative ring, then every idempotent of $A/\sqrt{0}$ lifts to some idempotent of $A$ (in fact uniquely, but we won't need that).

Once we have proven the lemma, we can solve the problem: With the notation as in the question, choose $x \in \mathfrak{a}$ and $y \in \mathfrak{b}$ with $x+y=1$. Then $x^2+xy=x$ shows that $x^2-x \in \mathfrak{a} \cap \mathfrak{b}$ and is therefore nilpotent, thus $x$ becomes idempotent in $A/\sqrt{0}$, and we can apply the Lemma.

For the proof of the lemma, assume that $x \in A$ and $x^2-x$ is nilpotent, so there is some $n \in \mathbb{N}$ with $0 = (x^2-x)^n=x^n (x-1)^n$. Since $x^n$ and $(x-1)^n$ are coprime, the Chinese Remainder Theorem gives us $A \cong A/x^n \times A/(x-1)^n$. The preimage of $(0,1)$ is an idempotent $e \in A$ such that $x-e$ is nilpotent (since this is the case in both factors), so that $e$ is the desired lift.

There is a connection between these two proofs: The Chinese Remainder Theorem is just the sheaf property of $\mathcal{O}_{\mathrm{Spec}(A)}$ applied to disjoint open subsets.


This is similar to BenjaLim's answer. I know this is an old question, but I am answering only because I was trying to come up with a much simpler solution than the ones I have found. It seemed like even using something as elementary as the Chinese Remainder Theorem was unnecessary. Eisenbud breaks down the problem much more clearly than Atiyah and MacDonald in exercise 2.25 in his commutative algebra text, which helped me a lot.

Since $\mathfrak{a} + \mathfrak{b} = (1)$, we have $a \in \mathfrak{a}$ and $b \in \mathfrak{b}$ such that $a + b = 1$. Now let's look at $1 = (a + b)^{2n}$ where $n$ is such that $(ab)^n=0$. Since commutative rings have the binomial theorem, we can expand:

$$(a+b)^{2n} = a^{2n} + \ldots + b^{2n}$$

Let $$e_1 = a^{2n} + \binom{2n}{1}a^{2n-1}b + \ldots + \binom{2n}{n-1}a^{n+1}b^{n-1}$$

and $$e_2 = b^{2n} + \binom{2n}{1}b^{2n-1}a + \ldots + \binom{2n}{n-1}b^{n+1}a^{n-1}$$

Notice that I left out $\binom{2n}{n}a^nb^n$ since this is just zero. Now $e_1 + e_2 = 1$ and $e_1e_2 = 0$ (every term in $e_1$ has $a^{n}$ and every term in $e_2$ has $b^{n}$). So $e_2 = 1 - e_1$ and $$e_1e_2=e_1(1-e_1) = e_{1} - e_{1}^2=0 \Rightarrow e_1=e_{1}^2$$

Similarly for $e_2$, we see that $e_1$ and $e_2$ are idempotents. Well, how do we know that they are nontrivial? We only need to see that $e_1$ is an element in $\mathfrak{a} \neq (1)$ and $e_2 \in \mathfrak{b} \neq (1)$, so neither of them are $1$, and thus by the identity $e_1 + e_2 = 1$, neither of them can be zero as well.


I was wrong previously and indeed we need to do some work. If $\mathfrak{a} + \mathfrak{b} = 1$, there exists $x \in \mathfrak{a}$ and $y \in \mathfrak{b}$ such that $x +y =1 $. Now by your observation above we have $(xy)^n = 0$ for some $n$ since $xy \in \mathfrak{a} \cap \mathfrak{b} \subseteq \mathfrak{n}$. Now we have

$$1 = (x+y)^n = x^n + y^n +xy(\operatorname{some terms}) $$

and so $x^n + y^n = 1 - xyz$ where $z = (\operatorname{some terms})$. Now $xy$ is nilpotent and $1$ is a unit so by Exercise 1.1 we have there exists $v \in A$ such that $v(x^n +y^n)= 1$. Then

$$(vx^n) = (vx^n)(v(x^n + y^n)) = v^2x^{2n}$$

and similarly for $vy^n$. Now show that one of these is not equal to $1$ or $0$.