To calculate acceleration