Question: I'm trying to make slide navigation. Here is my code

html

```
<li>
    <a href="#">Services</a>
   <div class="subcategories">
    <a href="#">Cleaning</a>
  </div>
</li>

```

The subcategories div is hidden.

js

```
$('li a').hover(function() {
  $(this).next().slideToggle('fast', function() {

   });
});

```

This code works. The problem is that when the mouse goes out of the li a the subcategories div disappears. 

What i want is that when the user point the li a the subcategories div to be shown so the user be able to click on some link of the sub navigation.

Answer: 
Assuming that you want to solve in the least squares sense, then you have a quadratic programming problem. For example, say that your set of vectors is

```
x1 = 1 2 3]'    x2 = [3 2 1]'

```

and your target vector is

```
H = [1 -1 1]'

```

Then you can create the matrix whose columns are your vectors:

```
A = [1 3;
     2 2;
     3 1]

```

and the thing you are trying to minimize is

```
norm(A*x - H) = (A*x - H)' * (A*x - H) = x' * (A'*A) * x - (2*H'*A) * x + const

```

If you define

```
B = A' * A
C = -2 * H' * A

```

then you have a problem that can be solved optimally my Matlab's `quadprog` function

```
quadprog(B,C,[],[],[],[],0,1)
ans = 
    0.16667
    0.16667

```

so the optimal solution in this case is

```
1/6 * x1 + 1/6 * x2 = [2/3, 2/3, 2/3]

```
This is a combinatorial optimization problem. This kind of problems are NP-hard. But I guess for the binary one, there should be polynomial algorithms that can solve, or there may be some relaxation to get an approximate solution. Some googling on "integer programming" may help.