0
$\begingroup$

I have 2 vectors, A and B, each with size n. Euclidean distance (or squared euclidean distance) can be calculated between this two vectors. I want to modify the vector B such that this distance is minimized. But the modifications must be applied to B as a whole. (multiplication to all elements, addition to all elements)

In mathematic term this should be $$ minimize \sqrt{\sum_{i=1}^n (A_i - k(B_i+x))^2} $$ Where k is a scalar to multiply to B and x is a scalar to add to B. I am finding k and x such that it minimize the distance of A and B.

$\endgroup$

1 Answer 1

1
$\begingroup$

Write $A = (A_1,..,A_n)$ and $B' = (k(B_1+x),..,k(B_n+x))$. Then I guess the shortest distance is $0$, so that we have $$A_1 = kB_1+kx$$ and $$A_n = kB_n+kx$$ So that subtracting the first to the second we get $$k = \frac{A_n-A_1}{B_n-B_1}$$ and then you plug back in and obtain $$x = \frac{A_1B_n-B_1A_n}{A_n-A_1}$$

$\endgroup$
1
  • $\begingroup$ Given this $k,x$, I don't think we know that $A_2 = kB_2 + kx$ $\endgroup$
    – nivekgnay
    Dec 9, 2016 at 3:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .