Formula for measuring foam density