Minimizing the sum of squares of the distances
Let's start by doing it for two points. We know the point that minimizes the sum of the squared distances is the bisector of the segment between them, but let's pretend we don't know that and want to invoke the machinery of calculus. Let the two points be $(a_1,b_1)$ and $(a_2,b_2)$ We want to minimize $$A=(a_1x)^2+(b_1y)^2+(a_2x)^2+(b_2y)^2$$ with respect to $x,y$. We can't set $A$ to zero as it is the sum of squares, so will be positive unless our three points are coincident. What we can do is that the partial derivatives of $A$ with respect to $x,y$ and set them to zero. We find $$\frac {\partial A}{\partial x}=2a_1+2x2a_2+2x$$ If we set that to zero we find $$x=\frac 12(a_1+a_2)$$ and similarly in $y$ so the point that minimizes $A$ is the midpoint of the segment between the two points.
You need to make the same argument for an arbitrary number of points. It works the same but you need a bunch of summation signs in yours.
Related videos on Youtube
O. Bates
Updated on April 22, 2020Comments

O. Bates over 3 years
I'm given $n$ fixed points $(a_1,b_1)...(a_n,b_n)$ and told to show that the sum of the squares of the distances from a point $P(x,y)$ to those fixed points is minimized when $x$ is the average of all the $a$ coordinates and $y$ is the average of all the $b$ coordinates.
I initially went about it by setting the sum of the squares of the distances equal to zero, so $0=(a_1x)^2+(b_1y)^2+(a_2x)^2+(b_2y)^2+...+(a_nx)^2+(b_ny)^2$ and then said that this would only work if $a_1+a_2+...+a_n=nx$ and, when simplified, $x$ would equal the average of all the $a$ coordinates. I'm not entirely sure I did this right, though, because I believe I'm expected to use gradients  I'm stuck on where I would include them. Could someone verify what I did makes sense or get me on the right track?

zipirovich over 5 yearsIf you think about it for a moment, you should see that It is extremely unlikely that the sum of a bunch of squares would be equal to zero... In fact, unless you have only one point (or the same point repeated multiple times), it's simply impossible.


O. Bates over 5 yearsThank you so much, I understand how to proceed from here!