Optimal partitions for the fast multipole method