Strictly speaking, a least squares fit is not defined for a vertical line (since
the error for each point is measured parallel to the Y axis).
However, if you swap X and Y, you can find the horizontal line with the best least
squares fit. It works out to simply the mean of the Y coordinate values:
The equation for a horizontal line is simply y = b.
The error at each point (xi, yi) is (yi - b).
The sum of the squares of the errors is SSE = sum( (yi - b)2). We wish
to find the value of b that minimizes SSE. Take the partial derivative of SSE with
respect to b and set it to zero:
sum(-2(yi - b)) = 0
Simplifying,
sum(yi) - Nb = 0
and
b = sum(yi)/N
So in your case, averaging the X coordinates gives you the X coordinate of
the vertical line that best fits your points.