Message Boards Message Boards

Eliminate produced redundant equations?

Posted 8 years ago

The following is one of the simplest example I could find to produce this behavior of "Eliminate": Imagine that 2 vectors a={a1,a2,a3} and b= {b1,b2,b3} are given and we search a vector z={z1,z2,z3} perpendicular to a and b. This gives following equations:

eq1={  
a.z==0,  
b.z==0 
}

Now apply one of the simplest coordinate transformations: z->u: ct={z1->u1,z2->u2,z3->u3+1}

eq1/.ct

resulting in the following 2 equations:

{a1 u1 + a2 u2 + a3 (1 + u3) == 0,   
b1 u1 + b2 u2 + b3 (1 + u3) == 0}

So far nothing exciting. Now lets do the same using "Eliminate".

eq2={  
   z1==u1,  
   z2==u2,  
   z3==u3+1,  
  a.(z/.ct) ==0,  
  b.(z/.ct) ==0  
}

and feed it to Eliminate to get rid of z1,z2,z3:

Eliminate[eq2,{z1,z2,z3}] //Simplify

this gives:

a3+a1 u1+a2 u2+a3 u3==0 &&  
b3+b1 u1+b2 u2+b3 u3==0 &&  
a1 (b3+b2 u2+b3 u3)==b1 (a3+a2 u2+a3 u3)

We get 3 equations! The first two equations are our equations from above, but the third one is a redundant linear depended equation.

Lets make things worse by additionally requiring that z is normalized:

eq3={  
   (z/.ct).(z/.ct) == 1,  
   z1==u1,  
   z2==u2,   
   z3==u3+1,  
  a.(z/.ct) ==0,  
  b.(z/.ct) ==0  
}

Feeding this to "Eliminate":

Eliminate[eq3, {z1, z2, z3}] // Simplify

we now get 5 equations, the first 3 the expected ones and two additional ones:

a3+a1 u1+a2 u2+a3 u3==0 &&  
b3+b1 u1+b2 u2+b3 u3==0 &&  
u1^2+u2^2+u3 (2+u3)==0 &&  
a1 (b3+b2 u2+b3 u3)==b1 (a3+a2 u2+a3 u3) &&  
a1 (-b3 u2 (1+u3)+b2 u3 (2+u3))==a3 (b2 u1-b1 u2) (1+u3)+a2 (-b3 u1 (1+u3)+b1 u3 (2+u3))

I would be grateful if somebody can explain me this behavior.

POSTED BY: Daniel Huber
18 Replies

It must be observed that the system eq2 may be written in the equivalent form:

eq2 = {
u1 - z1 == 0,
u2 - z2 == 0,
u3 - z3 == -1,
a1 u1 + a2 u2 + a3 u3 == -a3,
b1 u1 + b2 u2 + b3 u3 == -b3
}

The matrix of this system of 5 linear equations and 6 variables (u1, u2, u3, z1, z2, z3) is:

{{1, 0, 0, -1, 0, 0}, {0, 1, 0, 0, -1, 0}, {0, 0, 1, 0, 0, -1}, {a1, 
   a2, a3, 0, 0, 0}, {b1, b2, b3, 0, 0, 0}} // MatrixForm

enter image description here

The rank of this matrix is equal to 3! Conclusion: there are no redundant equation in the system obtained after Eliminate!

Replacement in eq1 is not an equivalent transform with adding 3 independent equations (see 3 first equations in eq2).

So, all is correct!

That rewrite requires that the a and b variables be regarded as parameters rather than algebraic variables. Which might or might not be what was intended.

POSTED BY: Daniel Lichtblau

Yes! a and b are regarded as the coefficients!

But Eliminate does not know which are to be regarded as coefficients and which as variables. So this matrix approach is not a faithful representation of the actual elimination.

POSTED BY: Daniel Lichtblau

I started from initial interpretation that a and b are two given vectors, i.e. their coordinates are fixed. But, if we think about coordinates of a and b as variables, the equations are bi-linear that makes equations somewhat simpler for Eliminate[].

Posted 8 years ago

Can you explain this in more details. The rank of this matrix is 5. If we use up 3 equation by the elimination we are left with 2 not 3.

POSTED BY: Daniel Huber

I apologize for being so late.

The rank of the matrix is 5.

In[35]:= MatrixRank[{{1, 0, 0, -1, 0, 0}, {0, 1, 0, 0, -1, 0}, {0, 0, 
   1, 0, 0, -1}, {a1, a2, a3, 0, 0, 0}, {b1, b2, b3, 0, 0, 0}}]

Out[35]= 5

Excellent! This gives an explanation that the dimension of the set of solutions of eq2 is equal to 1 (6-5 : the number of variables minus the rank of the matrix).

So we can apply now eliminate:

In[36]:= Eliminate[eq2, {z1, z2, z3, u3}]

Out[36]= a3 b1 u1 + a3 b2 u2 - a2 b3 u2 == a1 b3 u1

More the more, we can apply Solve[]:

In[37]:= Solve[eq2, {u1, u2, u3, z1, z2, z3}]

During evaluation of In[36]:= Solve::svars: Equations may not give solutions for all "solve" variables.

Out[37]= {{u2 -> -(((a3 b1 - a1 b3) u1)/(a3 b2 - a2 b3)), 
  u3 -> -1 - ((-a2 b1 + a1 b2) u1)/(a3 b2 - a2 b3), z1 -> u1, 
  z2 -> -(((a3 b1 - a1 b3) u1)/(a3 b2 - a2 b3)), 
  z3 -> -(((-a2 b1 + a1 b2) u1)/(a3 b2 - a2 b3))}}

Both from Eliminate[] and Solve[] we obtain the same result relative to the dimension of the set of the solutions. It's equal to 1.

Additionally, we can apply Solve[] to the initial system:

In[38]:= Solve[{a1 u1 + a2 u2 + a3 (1 + u3) == 0, 
  b1 u1 + b2 u2 + b3 (1 + u3) == 0}, {u1, u2, u3}]

During evaluation of In[38]:= Solve::svars: Equations may not give solutions for all "solve" variables.

Out[38]= {{u2 -> -(((a3 b1 - a1 b3) u1)/(a3 b2 - a2 b3)), 
  u3 -> -1 - ((-a2 b1 + a1 b2) u1)/(a3 b2 - a2 b3)}}

Evidently, this system and eq2 has the same solution set. So, we must admit that the transformations are equivalent!

Posted 8 years ago

Eliminates produces a third new equation. Geometrically we get an additional plane containing the intersection of the two first planes. Therefore it is redundant for the problem at hand. But "Eliminate" has produced additional info, what surprises me.
I would like to understand this. Unfortunately I do not understand Groebner basis and what I find in the Wiki is a bit above my head. Can you point me to some simple explanation that a humble physician is able to understand?

POSTED BY: Daniel Huber

There are textbook references for Groebner bases, but even those are far from elementary. The one by Cox, Little, and O'Shea is perhaps most accessible, which still means it takes time and some amount of undergraduate math prerequisite. Possibly a decent place to look would be early articles by Bruno Buchberger (who named them for his thesis advisor).

In very brief terms, Groebner bases generalize both Gaussian elimination (the linear case) and the Euclidean algorithm (the univariate case). Given a set of polynomials they come up with another set generating the same "polynomial space" (ideal, in the language of algebra) but with a certain nice property: any element in the space can be "reduced" to zero, by a form of generalized division by the Groebner basis. This property will not in general hold for the original set. A set with this property gives a nice algorithmic way of determining membership (and that was the original purpose of Buchberger's work, 50+ years ago).

These bases are with respect to what are known as "term orders". It happens that certain term orders can be used for elimination of variables (meaning: the result is a Groebner basis for the subset of polynomials in the original set that do not contain the eliminated variables).

I realize this is probably too brief a description to be helpful. But if one wants to know what elimination of variables is doing, one has to deal with a bit of hard-core algebra (I just hope "deal with" is not "suffer with").

POSTED BY: Daniel Lichtblau
Posted 8 years ago

Thank you Daniel, the " Cox, Little, and O'Shea" seems to be digestible.

POSTED BY: Daniel Huber
Posted 8 years ago

Hello Daniel, I am busily reading Cox, Little, and O'Shea. It is hard work, but well spent and not only "digestible" but even delicious. Here is what I found so far ( hopefully I understood everything o.k. and am not barking up the wrong tree):

Lets start with the equation from Eliminate (from above):

a3+a1 u1+a2 u2+a3 u3==0 &&
b3+b1 u1+b2 u2+b3 u3==0 &&
a1 (b3+b2 u2+b3 u3)==b1 (a3+a2 u2+a3 u3)

I claim that this set is linear dependent. As you pointed out, I wrongly claimed that the third equation is dependent on the first two. Because you said this, I stopped thinking (intimidation-by-expert-spell!) and it took me some time to get over it and realize that the set IS linear dependent. You can e.g. express the first one by the remaining ones:

eq= {a3+a1 u1+a2 u2+a3 u3,
b3+b1 u1+b2 u2+b3 u3,
a1 (b3+b2 u2+b3 u3)-(b1 (a3+a2 u2+a3 u3)) };

{a1/b1,-1/b1} . eq[[2;;3]] == eq[[1]] //Simplify
True

Well, why does "Eliminate " give linear dependent answers? Let's look what "Groebner Basis" has to tell. We start with eq2, rewritten from equation to polynomial form and calculate the Groebner basis (using lexicographical ordering. Remember z and u are variables, a and b parameters):

eq2a={
z1-u1,
z2-u2,
z3-1-u3,
a1 u1+a2 u2+a3 (1+u3),
b1 u1+b2 u2+b3 (1+u3)};

vars={z1,z2,z3,u1,u2,u3};
GroebnerBasis[eq2a,vars]

{-a3 b1+a1 b3-a2 b1 u2+a1 b2 u2-a3 b1 u3+a1 b3 u3,
b3+b1 u1+b2 u2+b3 u3,
a3+a1 u1+a2 u2+a3 u3,
-1-u3+z3,
-u2+z2,
-u1+z1}

I claim that this is not a reduced Groebner basis and therefor not minimal. To be a reduced basis, no monomial term of any basis polynomial can lie in the affine variety of the leading terms of the remaining polynomials. (Whow quite a mouth full!)

We need only look at the leading terms. The leading terms are:
{(-a2 b1+a1 b2) u2, b1 u1, a1 u1, z3, z2,z1}

it is quite obvious that the second and third term are dependent. I think this is the reason that "Eliminate" gives linear dependent solution sets.

POSTED BY: Daniel Huber

Daniel,

GroebnerBasis by default treats all indeterminates as "variables". To get the ones not listed to be seen as "parameters", use CoefficientDomain->RationalFunctions.

eq2a = {z1 - u1, z2 - u2, z3 - 1 - u3, a1 u1 + a2 u2 + a3 (1 + u3), 
   b1 u1 + b2 u2 + b3 (1 + u3)};
vars = {z1, z2, z3, u1, u2, u3};
gb = GroebnerBasis[eq2a, vars, CoefficientDomain -> RationalFunctions]

(* Out[1198]= {a3 b1 - 
  a1 b3 + (a2 b1 - a1 b2) u2 + (a3 b1 - a1 b3) u3, -a3 b2 + 
  a2 b3 + (a2 b1 - a1 b2) u1 + (-a3 b2 + a2 b3) u3, -1 - u3 + z3, 
 a3 b1 - a1 b3 + (a3 b1 - a1 b3) u3 + (a2 b1 - a1 b2) z2, -a3 b2 + 
  a2 b3 + (-a3 b2 + a2 b3) u3 + (a2 b1 - a1 b2) z1} *)

Here we show that no lead term divides another in Q(a,b).

leadterms = 
 GroebnerBasis`DistributedTermsList[gb, vars, 
   CoefficientDomain -> RationalFunctions][[1, All, 1]]

(* Out[1199]= {{{0, 0, 0, 0, 1, 0}, a2 b1 - a1 b2}, {{0, 0, 0, 1, 0, 0}, 
  a2 b1 - a1 b2}, {{0, 0, 1, 0, 0, 0}, 1}, {{0, 1, 0, 0, 0, 0}, 
  a2 b1 - a1 b2}, {{1, 0, 0, 0, 0, 0}, a2 b1 - a1 b2}} *)

There are a couple of important things to keep in mind. One is that Eliminate is based on ancient design and code. It has no concept of "parameters" and every indeterminate is either a variable to be eliminated or one to be retained (I made a comment to this effect a few days ago in this thread). The other, as noted above, is that GroebnerBasis has a default setting and it might not be the one that is what you implicitly have in mind.

POSTED BY: Daniel Lichtblau
Posted 8 years ago

Daniel, thanks a lot. The hint about "CoefficientDomain" really helps, I do not think I would have realized this myself.

Now the problem with "Eliminate". Is it too naive an approach to simply test the output of Eliminate for linear dependencies and eliminate if necessary. Or is the problem more subtle?

POSTED BY: Daniel Huber

If you have in mind that certain unknowns are coefficients rather than variables, then it will be tricky to use results from Eliminate no matter how you post-process. Offhand I do not know if Gaussian elimination will work for this purpose although it seems at least plausible.

There were a pair of papers from 1987, by Michael Kalkbrenner (Solving systems of algebraic equations using Gr\"obner bases) and Patrizia Gianni (Properties of Gr\"obner bases under specialization) respectively. They appeared one after the other in the Proceedings of the 1987 European Conference on Computer Algebra (EuroCAL). They show more or less how to handle this situation provided that the "parameter" indeterminates are ordered lexically lower than the "variable" indeterminates. If you do not specifiy certain indeterminates then Eliminate will in fact order them last, so this result could I guess be useful. But the details of how to use it are not so straightforward.

What I would advocate in any case is just using GroebnerBasis with CoefficientDomain -> RationalFunctions and also, for improved computational efficiency, MonomialOrder->EliminationOrder and Sort->True.

POSTED BY: Daniel Lichtblau
Posted 8 years ago

O.k. I take your advice. GroebnerBasis seems to be the way to go. And it also has a nice psychological aspect by using a new technique just learned. thank's for all, Daniel

POSTED BY: Daniel Huber

I don't see the linear dependency of a1 (b3+b2 u2+b3 u3)==b1 (a3+a2 u2+a3 u3) on the set

{a3+a1 u1+a2 u2+a3 u3==0,
b3+b1 u1+b2 u2+b3 u3==0}
POSTED BY: Daniel Lichtblau
Posted 8 years ago

You are right, I must have made a mistake when checking for dependency. However, now it is even worse,the third equation is additional information. Where does it coming from?

POSTED BY: Daniel Huber

The full result comes from a Groebner basis computation with a term ordering that eliminates the variables requested.

POSTED BY: Daniel Lichtblau
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