density calculation