Minimizing distance: distance formula

I am writing a program in C. I want to find a solution while minimizing the expression

D1+D2+......+Dn

where Di are the distances calculated by the formula of the distance between two points. The above expression is in variables x and y

Now I will differentiate this expression and find a solution. I doubt:

since in the above expression all Di will meet as square roots, which will be difficult to solve. So instead we can solve this:

D1^2 + D2^2 + ......+ Dn^2

Will the answer expressed by the above expression be the same as when creating the original solution?

I checked simple test cases like n = 2. It gives the correct answer. Is this true in general?

If not, how to solve this problem?

+5
5

, , , a^2 + b^2 , a + b. , . , , ; , , , .

, ? , , ; .

, , , , , , .

.. , . : , . sqrt ; (AFAIK). 100% , , , , , ; .

, , , , , , , (, ).

+7

. D1 + D2 D1^2 + D2^2 , D1 D2.

EDIT , , :

, D1 D2 , , D1^2 + D2^2, D1 + D2, .

(0,0), (1,0) (10, 0): |x|+|x-1|+|x-10| x^2+(x-1)^2+(x-10)^2

+2

D1, D2,.. Dn, , P1, P2,..., Pn xy, p0 = (x0, y0), P1.. Pn p0.

, D1.. Dn :

D1 = sqrt((x0-x1)^2 + (y0-y1)^2)
D2 = sqrt((x0-x2)^2 + (y0-y2)^2)
..
Dn = sqrt((x0-xn)^2 + (y0-yn)^2)

x1 .. xn y1 ... yn , x0, y0 . D0:

D0 = D1+D2+......+Dn

, . .

Update: , P0 (, ). , y0 x0:

y0 = a*x0 + b

a b. .

D1 = sqrt((x0-x1)^2 + (ax0+b-y1)^2)
D2 = sqrt((x0-x2)^2 + (ax0+b-y2)^2)
..
Dn = sqrt((x0-xn)^2 + (ax0+b-yn)^2)

n , * , x x1.. xn, x-, y0, D0.

+2

:

d1 = 1 d2 = 10 ( = 11 sumOfSquares = 101)

d1 = 6 d2 = 6 ( = 12 sumOfSquares = 72)

, .

0

, . , , . (ai) (ai ^ 2), ; , :

||x||2       <= ||x||1 <= sqrt(n)||x||2
||x||_\infty <= ||x||2 <= sqrt(n)||x||_\infty
||x||_\infty <= ||x||1 <=       n||x||_\infty

||x||2 - , ||x||1 - sum(abs(x1)+abs(x2)+...+abs(xn)), ||x||_\infty - max(abs(x1),abs(x2),...,abs(xn)). ( , .

( ) " ".

0

All Articles