added derivation for velocity