# Mathematica algorithm to minimize summation

GROUPS:
 Hi all!I'm new in Mathematica's world, but i urgently need an algorithm:data  = {1,3,5,6,7}     // a set of n data[size=2]Sum[ Min[  | x_i   -  x_a | ,  | x_i  - x_b | ] , i from 1 to n ]     where x_i \in data [/size]I have to find the (x_a,x_b) that minimize this Sum..Can someone help me? Thank you very much!!
1 year ago
4 Replies
 Daniel Lichtblau 1 Vote Are x_a and x_b also in the data set? If so, any reason not to do a brute-force search?Is this a one-off problem, that is, only for this data set, or is it something you might need to solve for many such sets?Is there a motivation for this problem? (Read: Is it something *other* than homework?)