A common approach for comparing the structures of biomolecules or solid bodies is to translate and rotate one structure with respect to the other to minimize the pointwise root-mean-square deviation (RMSD). We present a new, robust numerical algorithm that computes the RMSD between two molecules or all the mutual RMSDs of a list of molecules and, if desired, the corresponding rotation matrix in a minimal number of operations as compared to previous algorithms. The RMSD gradient can also be computed. We address the problem of symmetry, both in alignment (possible alternative alignments due to indistinguishable atoms) as well as geometry. In the latter case, it is possible to have degenerate superposition. A necessary condition is optimal superimposability to one's mirror image. Double (respectively, triple) degeneracy results in a one- (respectively, two)-parameter family of rotations leaving the superposition invariant. The software, frmsd, is freely available at http://www.ams.stonybrook.edu/~coutsias/codes/frmsd.tgz. © 2019 Wiley Periodicals, Inc.