Computing the dot product and angle between two vectors