I'm going through coordinate geometry chapter and I cannot understand where the formula below comes from.
Let $X$ and $Y$ be distinct point. The line from $O$ to $X-Y$ is parallel to line from $Y$ to $X$. A point on the line from $Y$ to $X$ is of the form:
$$P = Y + a(X - Y) = aX + (1 - a)Y,$$
where $a$ is a real number.
The following diagram should help you visualize the relationship of all the points.
As you can see in the diagram, the line from $O$ to $X-Y$ is parallel to the line from $Y$ to $X$ and the point $P$ on this line is just $P=Y+Z$, with $Z= a(X-Y)$.