Let be given three points $A(1,4,5)$, $B(3,4,0)$, $C(2,-1,0)$ and the sphere has equation $$(x-1)^2+(y+1)^2 + (z-3)^2=1$$ Let $N$ lies on the sphere. Find the least and the greatest of the value $$P=NA^2 + NB^2 + 3NC^2$$
I tried. Let $N(x,y,z)$ lies on the sphere. We have $$(x-1)^2+(y+1)^2 + (z-3)^2=1$$ and $$NA^2 + NB^2 + 3NC^2=\left(x-1\right)^{2}+2 \left(y-4\right)^{2}+\left(z-5\right)^{2}+\left(x-3\right)^{2}+4 z^{2}+3 \left(x-2\right)^{2}+3 \left(y+1\right)^{2}$$ or $$P=5x^2 + 5y^2 + 5z^2 - 20x - 10y - 10z + 82.$$ From here, I cannot solve the problem.
Hint: $\;$ the discrete form of the parallel axes theorem for the second moment of area for $\,n\,$ points $\,A_k\,$ with centroid $\,G\,$ and an arbitrary point $\,P\,$ is $\,\sum_{k=1}^n PA_k^2 = n \cdot PG^2 + \sum_{k=1}^n GA_k^2\,$. This can be easily proved using vectors:
$$ \require{cancel} \begin{align} \sum_{k=1}^n \big|PA_k\big|^2 = \sum_{k=1}^n \big|\overrightarrow{PG}+\overrightarrow{GA_k}\big|^2 = n \cdot\big|PG\big|^2 + \sum_{k=1}^n \big|GA_k\big|^2 + \cancel{2 \,\big\langle \overrightarrow{PG}, \,\underbrace{\sum_{k=1}^n \overrightarrow{GA_k}}_{=\,0} \big\rangle}\, \end{align} $$
Using the theorem for $\,P \equiv N\,,\,$ $\,n=5\,,\,$ $\,A_1=A\,,\, A_2=B\,,\, A_3=A_4=A_5 = C\,,$ $\, \overrightarrow G = \frac{1}{5}\big(\overrightarrow{A_1}+\overrightarrow{A_2}+\overrightarrow{A_3}+\overrightarrow{A_4}+\overrightarrow{A_5}\big) = \frac{1}{5}\big(\overrightarrow{A}+\overrightarrow{B}+3\,\overrightarrow{C}\big)$:
$$ NA^2+NB^2+3NC^2 \,=\, 5\, NG^2 + GA^2 + GB^2 + 3\,GC^2 $$
Therefore the sum on the LHS attains the maximum (or minimum) whenever $NG$ attains the maximum (or minimum), and the problem reduces to finding the points $\,N\,$ on the sphere farthest from (or closest to) fixed point $\,G\,(2, 1, 1)\,$.