# A solution for equation with N unknowns with specific constraints?

I am working with granular materials (seeds). I am looking for a way to correctly scale the amount of different particles in one batch using weight only. I have worked with the problem a bit and instead of going in detail with the applied problem, I will try to present the problem more generally.

Let's say I have the following equation: $\sum_{i=1}^{n} x_i = 1$, for all $x_i \in \mathbb{R}$ and $x_i > 0$. I would like to solve for all $x_i$. Solving this problem, solves the applied problem.

I have the following constraints: $x_i / x_j = a_i b_i / a_j b_j$, for all $i,j = 1, 2, \ldots, n$.

Also, for all $a_i \in \mathbb{R}$, $a_j > 0$, $b_i \in \mathbb{R}$, $b_j > 0$, $\sum_{i=1}^{n} a_i = k$, and $k > 0$ (where usually $k = 1$).

All $a_i$, $b_i$ and $k$ are given as input to the the problem.

For $n=1$ and $n=2$ the problem is trivial (or atleast easy). But I am not sure about $n>2$. Is there a general solution?

-

Let $$S = \sum_{i=1}^{n} a_i b_i$$

then $$x_i = \frac{a_ib_i}{S}$$

is a solution.

Note that $$\sum_{i=1}^{n} x_i = \sum_{i=1}^{n} \frac{a_i b_i}{S} = \frac{\sum_{i=1}^{n} a_i b_i}{S} = \frac{S}{S} = 1$$

$$\frac{x_i}{x_j} = \frac{a_ib_i/S}{a_jb_j/S} = \frac{a_ib_i}{a_jb_j}$$

Also note that $x_i \gt 0$.

-
Your answer seems to work very well indeed. It is identical with my own answer for n=2. I will check later for n=3, but I am betting it will work out correctly for all n :) Thanks! This solves a lot for me. –  Ole Thomsen Buus Jan 19 '11 at 12:04
@kofler: I have added some more explanation :-) –  Aryabhata Jan 19 '11 at 12:05
Funny, had not really seen those equalities before now. Ofcourse! My own battle was with actually converting the applied problem to math. In that process certain things can be overlooked. Thanks again. –  Ole Thomsen Buus Jan 19 '11 at 12:16
@kohler: You are welcome! –  Aryabhata Jan 19 '11 at 12:23