Let z stand for an arbitrary complex number and denote by Im(z) its imaginary part. Then we want to minimize the expression
f(z)=∣Im(z)∣2+k=1∑n∣z−ak∣2.
If m denotes the centroid of the given points, so that m=n1∑k=1nak, then,
using ∣w∣2=wwˉ, we easily obtain
k=1∑n∣z−ak∣2=n∣z−m∣2+k=1∑n∣m−ak∣2.
Hence,
f(z)=∣Im(z)∣2+n∣z−m∣2+k=1∑n∣m−ak∣2.
But, if m=a+ib, z=x+iy, where a,b,x,y are real numbers, then
∣Im(z)∣2+n∣z−m∣2=y2+n[(x−a)2+(y−b)2]=n(x−a)2+y2+n(y−b)2,
which takes its minimum when x=a,y=nb/(n+1). Hence
min f = n 2 b^2}{(n+1)^2} + n b^2}{(n+1)^2} + ∑k=1n |m - a_k|^2 = n+1n(Im(m))2+∑k=1n |m - a_k|^2.