Message Boards Message Boards

0
|
5853 Views
|
16 Replies
|
7 Total Likes
View groups...
Share
Share this post:

Solving equation system with quadratic terms

Hello, I am trying to solve a system of equations

eqn = Table[(x[i] - a[i])*Sum[x[k], {k, 1, n}] + b[i]*x[i] == 0, {i, 1, n}]

in a fast way for the x[i] (coefficients a[i] and b[i] are known). I found that for n = 2, 3, 4, 5, 6 Mathematica can eliminate n-1 equations by

eqn1 = Eliminate[eqn, Table[x[i], {i, 1, n - 1}]]

and obtain a single equation, e.g. for x[n], in the form

c[0] + c[1] x + c[2] x^2 + ... + c[n+1] x^(n+1) == 0

with coefficients c[i]. It seems that there is some pattern in how these coefficients look, e.g. for c[1] and c[n+1] I found

c[1] == a[n]^(n - 1)*Product[b[i], {i, 1, n}]*(1 - Sum[a[i]/b[i], {i, 1, n}])
c[n+1] == Product[b[n] - b[i], {i, 1, n - 1}]

Are there similar (simple) rules for the other c[i]? That would allow to reduce solving the equation system to solving a single polynomial equation.

Thanks for your input, Max

Attachments:
16 Replies

Hello Henrik,

thank you for the clarification. This is actually a very elegant way of computing the solution in a simple way, without having to calculate any coefficients! Funnily (and understandibly), it is converging faster when n gets larger.

So that means, actually my problem is solved, since there is no need to calculate the coefficients of the the equation system.

BTW, the equations come from a mix of surfactants when put into a solution. Each compound for itself forms micelles at a certain critical concentration. But in a mix, the components partition between aqueous solution and micelles depending on their relative concentrations and critical micelle concentrations in the way described by the equation system.

Thanks again for all the input and help!

Max

Hello Henrik, thanks you for this idea, it is really good and simple. Although there is no possibility to find sum, and the above equation still requires solving a polynomial equation of the same order as before, it has the significant advantage that it is already posed in the simplified form that allows a quick calculation of the coefficients. Since sum is x[1]+...+x[n], the solution

x[i] == sum*a[i]/(sum+b[i])

can be used to re-write the problem as

sum - Sum[sum*a[i]/(sum+b[i]),{i,1,n}] == 0

In contrast to my above attempts, the solution is already in a simple form. Now I can hopefully directly calculate the coefficients for solving

c[0] + c[1]*sum + c[2]*sum^2 + ... + c[n+1]*sum^(n+1) == 0

Best, Max

Clearing denominators will put it into that form.

POSTED BY: Daniel Lichtblau

Hi Max,

OK, I will try again: As I proposed above one can use the equation

$$x_i = \frac{a_i \sum_k x_k}{b_i+\sum_k x_k}$$ for an iterative process. It might be not unreasonable to assume that

$$\big(\sum_k x_k\big) >(\gg) \;b_i \quad \text{(for any i)} $$

witch results as a first approximation: $$x_i \approx \frac{a_i \sum_k x_k}{\sum_k x_k} = a_i$$ This gives a first estimate for the sum which can be used for a better approximation for the $x_i$, and so on.

You did not give us the coefficient vectors a and b, so I am using random numbers.

dim = 15;
a = RandomReal[10, dim];
b = RandomReal[10, dim];

The iteration itself is pretty much straightforward:

newX[x_List] := With[{sum = Total[x]}, sum a/(sum + b)];
xList = FixedPointList[newX, a];

and one can watch the system converging:

ListPlot[Transpose[xList], Joined -> True, ImageSize -> Large, GridLines -> Automatic]

enter image description here

and finally one can check the result using the formula from your original post:

x = Last[xList];  (* final result! *)
Chop[(x - a)*Total[x] + b x] == ConstantArray[0, dim]
(*  Out:   True  *)

Does/will this work with your coefficients?

POSTED BY: Henrik Schachner

Hi Max,

I do not have a clean solution to your problem, but maybe some thoughts:

Your equation can be written in the form

eq = x[i] sum - a[i] sum + b[i] x[i] == 0

where sum simply is the sum of your unknowns x[i]. This of course can be solved:

enter image description here

If you have sum you are done! I do not know where your equation comes from, but maybe there is some argument on what that sum could be. Or at least if you can make some estimation about the sum you would get an approximation for the x[i]. Depending on the coefficients a[i] and b[i] this might serve as a single step of an iteration. Does that make sense to you?

POSTED BY: Henrik Schachner

Hello Richard,

typically n is not very high, in the range of 3-10. But since the ai and bi are going to be fit parameters and are different for every calculation of the xi, calculation speed plays an important role. Therefore, I am searching for a simple formula with a low number of operations.

Also, I am generally wondering if there is a formalism or tool to convert expressions like the c[i] to simpler formulas. FullSimplify is doing well if the result is just a product of sums and differences of the ai and bi (as for my example c[n+1]), but not if there are terms like ai/bi involved, as for c[1] and c[2] as above.

Max

Max, For the phenomena you are modeling, how large might n be?

POSTED BY: Richard Frost

Dimensionally it would make more sense as

xi•(x1 + … + xn) - ai•(x1 + … + xn) + bi == 0,  i = 1 to n.
POSTED BY: Richard Frost

I don't know why that would necessarily make more sense-- it depends on where the system arises. Also such a change would have at least two notable effects: the origin would (generically) not be a solution, and the solution count would be two rather than n+1.

POSTED BY: Daniel Lichtblau

Even if you obtain such formulas the result will not likely be very useful for solving the system. The formulas are large and substitution of values for the a and b parameters will likely give rise to cancellation error.

POSTED BY: Daniel Lichtblau

Ok, you would not use tools for linear systems on a vector equation containing the quadratic form x.M.x

Is your original formula correct?

Table[(x[i] - a[i])Sum[x[k], {k, 1, n}] + b[i]x[i] == 0, {i, 1, n}]

It produces n equations of the form:

xi•(x1 + … + xn) - ai•(x1 + … + xn) + bi•xi == 0,  i = 1 to n.
POSTED BY: Richard Frost

Hello Richard,

Yes the formula is correct, it is

xi•(x1 + … + xn) - ai•(x1 + … + xn) + bi•xi == 0,  i = 1 to n.

, so bi*xi and not just bi. One solution is xi = 0 for all i = 1...n.

I also found a formula for c[2]:

c[2] == a[n]^(n - 2) Product[b[i], {i, 1, n}] ((a[n] n)/b[n] + (b[n] - a[n]) Sum[1/b[i], {i, 1, n - 1}] - (n - 1) (1 - Sum[a[i]/b[i], {i, 1, n - 1}]) - b[n] (Sum[a[i]/b[i], {i, 1, n - 1}] Sum[1/b[i], {i, 1, n - 1}] - Sum[a[i]/b[i]^2, {i, 1, n - 1}]))

which is complicated, but the number of operations to calculate it is of order n and not n^2. I assume that there are also simple formulas for the other c[i], because when I extract all powers of an, bn, ai, bi in the coefficients c[i], I see a pattern that is similar for all c[i], see attached notebook. It gives a table for all terms that appear in the coefficients.

The columns are the powers of ai, bi (all i including n), an, bn, and the coefficient in front of each term. The last column gives the multiplicity of how many terms of this type appear, which is in this case the number of permutations that the indices i different from n allow.

E.g. for n=5, c[5] is

+b[4]^3

-b[1] b[4]^2
-b[2] b[4]^2
-b[3] b[4]^2

+b[1] b[2] b[4]
+b[1] b[3] b[4]
+b[2] b[3] b[4]

-b[1] b[2] b[3]

which gives the table entries

0   3 0   3 1   1
0   3 0   2 -1  3
0   3 0   1 1   3
0   3 0   0 -1  1

It is easy to find a rule for how all these terms are constructed for any n; the binomial coefficients in column 5 and their sign are determined by the powers of the a's and b's in columns 1-4. But as discussed above, my goal is to find a simpler rule for constructing them, with a lower number of operations.

Best, Max

Attachments:

"how can this system be solved algebraically?"

I am thinking of it as a vector equation solved by vector algebra. The way you're looking at it, you have rows of:

xi•(x1 + … + xn) - ai•(x1 + … + xn) + bi•xi == 0.

As a vector equation, the 3rd term is a matrix of all zeroes except b_i's down the diagonal, multiplying a column vector of x.

POSTED BY: Richard Frost

Hello Richard,

sure, I see that the system can be written in a vector form. But since there are quadratic terms xi*(x1+...+xn), I thought it cannot be solved by the tools for linear equations. But it has been a while since I studied these things in detail. If you are aware of a practical way to solve it algebraically, please post it.

Thanks,

Max

Hi Max, I believe your equation can be put in quadratic vector form

x^t.M.x

(x^t == x transpose) and then solved algebraically?

POSTED BY: Richard Frost

Hello Richard,

this is true, but how can this system be solved algebraically? I think it still requires solving a polynomial equation of order n+1.

I was able to find a formula for determining the coefficients for this polynomial equation, but it is quite complex. E.g. when you set n=5 and look at c[3], it contains 50 terms, each being a product of 7 a[i] or b[i]. For n=6 it is already 576 terms in total for all coefficients. Although I could figure out the pattern how to construct these coefficients for any n, I was wondering if there is a simpler way to express them, e.g. as products of a few terms, as the above examples for c[2] and c[n+1].

To make the example more explicit, for n=4, c[n+1] is:

-b[1] b[2] b[3] + b[1] b[2] b[4] + b[1] b[3] b[4] + b[2] b[3] b[4] - b[1] b[4]^2 - b[2] b[4]^2 - b[3] b[4]^2 + b[4]^3

which is 16 multiplications and 7 additions, but it can be simplified to

(b[4] - b[1]) (b[4] - b[2]) (b[4] - b[3])

which is 3 multiplications and 3 subtractions.

If it is possible to find a similar general rule for all coefficients, the calculation for higher n would be much accelerated.

Max

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract