Where Is the Sum of Squared Distances Minimized?
At a glance
- 1. Find the centroid
Average the coordinates of all given points to get their centroid.
- 2. Use the identity
Rewrite the total squared distance as a constant plus a nonnegative term measuring distance from the centroid.
- 3. Read off the minimum
The extra term is smallest at zero, so the centroid is the unique minimizer.
- 4. Check constraints
If the chosen point must lie in a restricted set, the unconstrained centroid may not be allowed.
If you can choose a point freely and want to minimize the sum of its squared distances to a fixed collection of points, the minimizing point is their centroid. This result holds in any finite-dimensional Euclidean space, not just in the plane.
The proof is short: express each point’s displacement from your chosen point as a displacement from the centroid plus a shared offset. When you square and sum, the cross terms cancel. The remaining expression shows exactly how much the total increases when you move away from the centroid.
The setup and answer
Let the fixed points be in , and let be the point you can choose. The objective is
Here, is the usual Euclidean distance. Define the centroid by averaging the points coordinate by coordinate:
Then has a unique minimum at . The points do not need to form a regular shape, and the centroid does not need to be one of the original points.
Why the centroid minimizes the sum
Write and expand the squared norm using the dot product:
The middle term is zero because
Therefore,
The first term is constant with respect to . The second is nonnegative and equals zero only when . This proves both that the centroid is a minimizer and that it is the unique minimizer.
You can also see the result by differentiating. In coordinates, the gradient of is , so setting it to zero gives . The identity above is often more informative: it directly tells you the increase in the sum for any chosen point.
Worked example
Take the three points , , and . Their centroid is
The squared distances from the centroid to the three points are
Their sum is . Thus the minimum total is , attained at . For any other point , the total is larger by .
Common mistakes
- Minimizing distances instead of squared distances. The result above is for . If the objective is , the minimizer is generally a geometric median, not the centroid.
- Using the wrong average. For equally weighted points, average each coordinate. For example, in two dimensions, average all the -coordinates and all the -coordinates separately.
- Assuming the minimizing point must be one of the given points. The centroid can lie between them, as it does in the example.
- Ignoring a constraint. The proof assumes can be anywhere in . If must lie on a particular line or in a closed convex region, the constrained minimizer is the point in that set nearest to the centroid. For a line, this is the perpendicular projection of the centroid onto the line.
Weighted points
If point has a positive weight , minimize . The same argument gives the weighted centroid
as the unique minimizer. A larger weight pulls the minimizing point more strongly toward its associated point.
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.