Is my reasoning correct (regarding minimal distance on graph) 
Question: Given two point $A(0,10)$ and $B(30,20)$, find the point $P$ on x axis for which sum of distances from given points to the required point is minimum  

Now i could form a lengthy equation and use differentiation but instead I decided to do something else and would like to verify if what i did is correct
Consider a triangle formed by above given points and $(x,0)$. Let the distance between $A$ and $B$ be $c$, distance between $P$ and $A$ be $a$ and distance between $P$ and $B$ be $b$.
By the cosine law $c^2=a^2+b^2-2ab\cos(\angle BPA)$. Now since c is constant, $a^2+b^2$ will be minimum when $2ab\cos(\angle BPA)=0$ and thus when $\angle BPA=\pi/2$
Now, since $PA$ and $PB$ intersect at $90\deg$, the product of thier slope = $-1$
$\implies {-10 \over x}{20 \over 30-x}=-1$
$\implies x=20$ or $10$
Is my reasoning correct? And why does it give two different answers? (Minima is at $10$)
According to my reasoning both answers should be minimal values
EDIT: I got why 20 doesnt give right answer. Its because I'm Minimizing $a^2+b^2$ while i need to minimize a + b. Does this invalidate the other part to? that is will it work on all triangles or not?

Your reasoning is not correct for a couple of reasons.


*

*You should be trying to minimise $a+b$, which is not the same thing as minimising $a^2+b^2$.

*It is possible for $ab\cos\angle APB$ to be negative, so $a^2+b^2$ isn't going to be minimised when $\cos\angle APB=0$.


You get two solutions because there are two places which make a right-angled triangle (the points of intersection between the $x$-axis and the circle with diameter $AB$). Neither of these is the minimum of $a^2+b^2$, which actually occurs when $x=15$. (To see this, note that $a^2=x^2+10^2$ and $b^2=20^2+(30-x)^2$, so it is the same as minimising $x^2+(30-x)^2=2(x-15)^2+450$.)
The fact that one of your points happens to minimise $a+b$ is just a coincidence, I'm afraid.
