Calculation of density and percent error