Analytical computation of the demagnetizing energy of thin-film domain walls