# Constructing Idempotent Generator of Idempotent Ideal

Exercise 2.1 in Matsumura's Commutative Ring Theory reads as follows: "Let $A$ be a commutative ring and $I$ an ideal that is finitely generated and $I=I^2$. Then $I$ is generated by an idempotent."

In trying to solve it, i first followed a constructive approach, where e.g. for the case of two generators i tried to construct an idempotent generator. However, it seemed difficult. Then i realized that i could apply Nakayama's lemma to the $A$-module $I$ and the existence of the idempotent generator follows.

My question is: How could one go about finding this idempotent generator? Is there a systematic way?

-
Suppose you know that the ideal is generated by $n$ elements, $(x_1, ..., x_n)$. By assumption, we may write $x_i = \sum a_{ij} x_j$, where the $a_{ij} \in I$. The element we're looking for is $p(1) -1$, where $p$ is the characteristic polynomial of the matrix $(a_{ij})$.