MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Identifying Linearly Dependent Equations

  • To: mathgroup at smc.vnet.net
  • Subject: [mg81308] Identifying Linearly Dependent Equations
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 19 Sep 2007 05:19:24 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • References: <200709170734.DAA15516@smc.vnet.net> <fcnkpb$s0k$1@smc.vnet.net>

%uvt_fullname% wrote:

> I am facing the following problem:

Note that I have changed the title of the thread. A meaningful title 
will attract more answers (and a valid email address allows you to get 
faster replies by direct email) and it is easier for people to find a 
thread that answers their questions.

> 1) I have a system of m=12 linear equations, with n=11 variables.
> 
> 2) I want to identify those linearly dependent equations and drop them from
> the system to have a solution.
> 
> 3) I applied the following code (somebody from MathGroup provided this last
> year), which is the Gram-Schmidt method of orthogonalization:
> 
> 
> Clear[V];
> 
> equ = {i - 0.4 p == 0, k - 0.16 z == 0, m - 0.9 p == 0, c - 0.83 r == 0, x -
> 0.7 p ==0, p + m - i - c - k - x == 0, y - p + i == 0, 
>   s - r + c == 0, b - m + x == 0, y - r == 0, k - s - b == 0, 
>   z - p - m == 0};
> 
> {h1, V} = CoefficientArrays[equ, {p, m, i, k, x, c, y, r, s, b, z}];
> 
> Do[Do[If[V[[n]] != {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, V[[m]] =
> (V[[n]].V[[n]]) V[[m]] - (V[[n]].V[[m]]) V[[n]]], {n, 1, m - 1}], {m, 2,
> 12}]
> 
> Map[If[# != {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "keep", "discard"] &, V]
> 
> 
> This Code always indicates the 6th row to be discarded no matter which order
> you input the equations in "equ".
> 
> Isn't there a problem with this code or maybe I am missing something.

At a first glance, the code seems fine for symbolic computation (I am 
rather condiment that what you are facing is numerical instability due 
to the use of inexact arithmetic). In the example below, we can see that 
by reversing the sequence of equations, we get nothing to discard. So 
use exact numbers or rationalize the equations first.

In[1]:= equ = {i - 0.4 p == 0, k - 0.16 z == 0, m - 0.9 p == 0,
    c - 0.83 r == 0, x - 0.7 p == 0, p + m - i - c - k - x == 0,
    y - p + i == 0, s - r + c == 0, b - m + x == 0, y - r == 0,
    k - s - b == 0, z - p - m == 0};

dependentQ[eqns_] :=
  Module[{h1, V}, {h1, V} =
    CoefficientArrays[eqns, {p, m, i, k, x, c, y, r, s, b, z}];
   Do[Do[If[V[[n]] != {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
      V[[m]] = (V[[n]].V[[n]]) V[[m]] - (V[[n]].V[[m]]) V[[n]]], {n, 1,
       m - 1}], {m, 2, 12}];
   Map[If[# != {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, "keep", "discard"] &,
     V]
   ]

dependentQ[equ]
dependentQ[Reverse@equ]
dependentQ[Sort@equ]

Out[3]= {"keep", "keep", "keep", "keep", "keep", "keep", "keep", \
"keep", "keep", "keep", "discard", "keep"}

Out[4]= {"keep", "keep", "keep", "keep", "keep", "keep", "keep", \
"keep", "keep", "keep", "keep", "keep"}

Out[5]= {"keep", "keep", "keep", "keep", "keep", "keep", "keep", \
"keep", "keep", "keep", "discard", "discard"}

In[6]:= equ = Rationalize[equ];
dependentQ[equ]
dependentQ[Reverse@equ]
dependentQ[Sort@equ]

Out[7]= {"keep", "keep", "keep", "keep", "keep", "keep", "keep", \
"keep", "keep", "keep", "discard", "keep"}

Out[8]= {"keep", "keep", "keep", "keep", "keep", "keep", "discard", \
"keep", "keep", "keep", "keep", "keep"}

Out[9]= {"keep", "keep", "keep", "keep", "keep", "keep", "keep", \
"keep", "keep", "discard", "keep", "keep"}

-- 
Jean-Marc


  • Prev by Date: Re: Re: LegendreP error (bug?) in Mathematica
  • Next by Date: Problem when NIntegrate matrix
  • Previous by thread: RE: Button Help Example
  • Next by thread: RE: Identifying Linearly Dependent Equations