We propose a fast iterative method to optimize coarse basis functions in al
gebraic multigrid by minimizing the sum of their energies, subject to the c
ondition that linear combinations of the basis functions equal to given zer
o energy modes, and subject to restrictions on the supports of the coarse b
asis functions. For a particular selection of the supports, the first itera
tion gives exactly the same basis functions as our earlier method using smo
othed aggregation. The convergence rate of the minimization algorithm is bo
unded independently of the mesh size under usual assumptions on finite elem
ents. The construction is presented for scalar problems as well as for line
ar elasticity. Computational results on difficult industrial problems demon
strate that the use of energy minimal basis functions improves algebraic mu
ltigrid performance and yields a more robust multigrid algorithm than smoot
hed aggregation.