Find maximum possible value of $(a-p)^2+(b-q) ^2$ Given that $$a^2+b^2-2a=0 $$ and $$p^2+q^2+8-6p=0 $$ then find the maximum value of $$p^2+q^2+a^2+b^2-2ap-2bq$$.
What I tried: From the first equation we get $$(a-1)^2+b^2=1$$ and from second equation we get $$(p-3)^2+q^2=1$$ and we have to find $$(a-p)^2+(b-q) ^2$$. Then I substituted $(a-1)= \sin x,  b= \cos x,  (p-3)= \sin y, $ and $q=\cos y$ and then tried to find the maximum value of the expression but couldn't get any answer.  I tried differentiating the equation and setting it to zero also but proved of no use please help.  Thanks in advance
 A: What we have is that $$(a-1)^2 + b^2 = 1$$ is the equation of a circle in $\mathbb{R}^2$ of radius $1$, centred at $(1,0)$, $$(p-3)^2 + q^2 = 1$$ is the equation of a circle in $\mathbb{R}^2$ of radius $1$, centred at $(3,0)$, and $$(a-p)^2 + (b-q)^2$$ is the square of the distance between two points $(a,b)$ and $(p,q)$ which lie on the respective circles.
Can you search for the two points on each circle that are farthest from each other, geometrically?
A: Given two circle sharing no interior points[*], maximizing the distance between two points, one on each circle, can be done by:


*

*Drawing the line through both centers.

*For each circle, pick the point that intersects this line which is not between the two centers.


You can prove this with the triangle inequality. If the circles have centers $O_1$ and $O_2$ of radius $r_1,r_2$, then picking points $P_1,P_2$ on the circles, you get:
$$|P_1P_2|\leq |P_1O_1|+|O_1O_2|+|O_2P_2|=r_1+r_2+|O_1O_2|$$
And the above gives this value.

[*] You can actually use this method if the circles intersect, as long as neither center is contained inside the other circle.
The method can be modified for the case when the circles are not concentric, but we don't need that here.
A: with the help of Lagrange Multipliers we get
$$(a-p)^2+(b-q)^2\le 16$$ and the equal sign holds if $$a=b=0,p=4,q=0$$
