5
$\begingroup$

If we have a system of variables, say,

eqnlist={1-y[1]==0,1/6 (6 y[1]-6 y[2])==0,1/4 (-4 x[1]+2 (2 y[2]-2 y[3]))==0,1/6 (-6-6 x[2]+6 y[3])==0,1-x[3]==0,1/6 (-6+6 y[1]-6 y[4])==0,1/2 (4 x[1]-2 y[1]+2 y[2]+2 y[4]-2 y[5])==0,1/2 (4 x[2]-2 x[4]-2 y[2]+2 y[3]+2 y[5])==0,1/6 (12 x[3]-6 x[5]-6 y[3])==0,1/4 (-4 x[1]+4 y[4]-4 y[6])==0,1/2 (-2 x[2]+4 x[4]-2 y[4]+2 y[5]+2 y[6])==0,1/4 (-4 x[3]+8 x[5]-4 x[6]-4 y[5])==0,1/6 (-6 x[4]+6 y[6])==0,1/6 (-6-6 x[5]+12 x[6]-6 y[6])==0,1-x[6]==0} 

how can we count the number of free variables?

My approach is to use Reduce@eqnlist, which outputs

y[5]==-2 y[6]&&y[4]==0&&y[3]==1+y[6]&&y[2]==1&&y[1]==1&&x[6]==1&&x[5]==1-y[6]&&x[4]==y[6]&&x[3]==1&&x[2]==y[6]&&x[1]==-y[6]

In this case, all the variables on the right side of each equation are free variables, and they uniquely determine the value of the variables on the left side of each equation.

But the output form of Reduced might not necessarily reflect the number of free variables for larger systems. Even if it does, I don't know how to extract "all variables on the right side of each equation".

$\endgroup$

2 Answers 2

5
$\begingroup$

You say the systen is linear. Thus, you only have to compute the dimension of the nullspace of the system matrix:

vars = Variables[eqnlist[[All, 1]]];
matrix = D[eqnlist[[All, 1]], {vars, 1}];
Length[NullSpace[matrix]]

1

$\endgroup$
2
  • 1
    $\begingroup$ Interesting. Never seen [[All, 1]] before. $\endgroup$ Commented Aug 6 at 11:18
  • 1
    $\begingroup$ @youthdoo : It extracts the left-hand side (part 1) from All equations in eqnlist. Note that this means that the code will need modification if you ever feed it an equation with variables on both sides; to ensure that all the equations are of the form expr == 0, you can invoke eqnlist = SubtractSides /@ eqnlist before the rest of the code. $\endgroup$ Commented Aug 6 at 21:08
4
$\begingroup$

Assuming your system is polynomial then number of independent variables is equal to the number of variables minus number of equations in Groebner basis of the system.

eqnlist = {1 - y[1] == 0, 1/6 (6 y[1] - 6 y[2]) == 0, 
   1/4 (-4 x[1] + 2 (2 y[2] - 2 y[3])) == 0, 
   1/6 (-6 - 6 x[2] + 6 y[3]) == 0, 1 - x[3] == 0, 
   1/6 (-6 + 6 y[1] - 6 y[4]) == 0, 
   1/2 (4 x[1] - 2 y[1] + 2 y[2] + 2 y[4] - 2 y[5]) == 0, 
   1/2 (4 x[2] - 2 x[4] - 2 y[2] + 2 y[3] + 2 y[5]) == 0, 
   1/6 (12 x[3] - 6 x[5] - 6 y[3]) == 0, 
   1/4 (-4 x[1] + 4 y[4] - 4 y[6]) == 0, 
   1/2 (-2 x[2] + 4 x[4] - 2 y[4] + 2 y[5] + 2 y[6]) == 0, 
   1/4 (-4 x[3] + 8 x[5] - 4 x[6] - 4 y[5]) == 0, 
   1/6 (-6 x[4] + 6 y[6]) == 0, 
   1/6 (-6 - 6 x[5] + 12 x[6] - 6 y[6]) == 0, 1 - x[6] == 0};
Length[Variables[List @@@ eqnlist]] - Length[GroebnerBasis[eqnlist]]

1
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.