In order to find the second endpoint or a line segment given the first and the midpoint, you need to realize that the midpoint is an average of the two endpoints. Given that fact, we can derive this formula looking at x values of points A and B with midpoint M. Remember this is only looking at the x values.
(A + B)/2 = M
So if we are looking for A, we can solve for A and use this modified formula.
(A + B)/2 = M
A + B = 2M
A = 2M - B
Now we can do this with the y values of these points as well. We then have the coordinates of both parts of A.