How to extract the indeterminates from a set of polynomial? I am a biologist and I am facing a huge problem. I would like to extract the indeterminates of a set of polynomials, for example, I have:
$f_{1} = \{\\x_{3}^{2} + x_{1}*x_{2} + x_{1} + x_{1}*x_{3},\\
x_{2}^{3}*x_{1}^{2} + x_{1}*x_{2}*x_{3} + x_{4}, \\ x_{2}^{2}+x_{4}+x_{4}^{3}+x_{2}+x_{2}*x_{4}\\
\}$
and I would like to have an automation of this process:
Process ("Extract the indeterminates of the set of polynomials fi)

$f_{1} = \{\\x_{3}^{2} + x_{1}*x_{2} + x_{1} + x_{1}*x_{3},\\
x_{2}^{3}*x_{1}^{2} + x_{1}*x_{2}*x_{3} + x_{4}, \\ x_{2}^{2}+x_{4}+x_{4}^{3}+x_{2}+x_{2}*x_{4}\\
\}$
Result

$f_{1, extracted} = \{\\(x_{1}, x_{2}, x_{3}),\\
(x_{1}, x_{2}, x_{3}, x_{4}), \\ 
(x_{2}, x_{4})\\
\}$
I have searched a method to do that in the documentations of Macaulay2, Magma, CoCoA and Mathematica but without success.
I hope you can help me! Without you, I will need to perform this manually (I have thousands of polynomials with different indeterminates combinations...). Thank you in advance!
Cheers,
Celina
 A: For example, this may be automated with GAP. Consider the following GAP session:
1) Create polynomial ring with as much variables as you may need:
gap> R:=PolynomialRing(Rationals,5);
Rationals[x_1,x_2,x_3,x_4,x_5]

Remark: one can always add more indeterminates later, e.g.
gap> Indeterminate(Rationals,11);
x_11

(as you could see, numbers of indeterminates need not to be consecutive)
2) Get a list of indeterminates
gap> x:=IndeterminatesOfPolynomialRing(R);
[ x_1, x_2, x_3, x_4, x_5 ]

to be able to address them by their position in the list x, for example
gap> x[4];
x_4

3) If you really need to parse the text where indeterminates are given using x_i notation, you could assign them programmatically, for example: 
gap> for i in [1..Length(x)] do BindGlobal(Concatenation("x_",String(i)),x[i]);od;

Now the following works:
gap> x_1;
x_1

4) Finally, after previous steps, I have created all the necessary setup to be able to reproduce three polynomials from your example:
gap> f1:=x_3^2 + x_1*x_2 + x_1 + x_1*x_3;
x_1*x_2+x_1*x_3+x_3^2+x_1
gap> f2:=x_2^3*x_1^2 + x_1*x_2*x_3 + x_4;
x_1^2*x_2^3+x_1*x_2*x_3+x_4
gap> f3:=x_2^2+x_4+x_4^3+x_2+x_2*x_4;
x_4^3+x_2^2+x_2*x_4+x_2+x_4

5) The following function will calculate so called "external representation of a polynomial" as a list of the form [mon,coeff,mon,coeff,...] where mon is a monomial in expanded form (that is given as list) and coeff is its coefficient:
NumbersOfIndeterminates:=function(f)
local r, i, j, u;
u:=[];
r:=ExtRepPolynomialRatFun(f);
for i in [1,3..Length(r)-1] do
  for j in [1,3..Length(r[i])-1] do
    AddSet(u, r[i][j] );
  od;
od;
return u;
end;

I will just paste this code into GAP:
gap> NumbersOfIndeterminates:=function(f)
> local r, i, j, u;
> u:=[];
> r:=ExtRepPolynomialRatFun(f);
> for i in [1,3..Length(r)-1] do
>   for j in [1,3..Length(r[i])-1] do
>     AddSet(u, r[i][j] );
>   od;
> od;
> return u;
> end;
function( f ) ... end

6) Now I am able to use it as intended:
gap> NumbersOfIndeterminates(f1);
[ 1, 2, 3 ]
gap> NumbersOfIndeterminates(f2);
[ 1, 2, 3, 4 ]
gap> NumbersOfIndeterminates(f3);
[ 2, 4 ]
gap> NumbersOfIndeterminates(Zero(R));
[  ]
gap> NumbersOfIndeterminates(Sum(x));
[ 1, 2, 3, 4, 5 ]

Some final remarks: I'd be interested to know in which form do you have the input data and do you have control over the syntax there. Do you have them as a text file? Can you just generate an input file for GAP? Are you able e.g. to change its format to use x[1] instead of x_1, etc.? Is there one line per polynomial in the text file or not? If not, how they are separated?
It is certainly possible to organise that GAP will read the text file line by line, parse and evaluate polynomials. It may also happen that one could the same without using any computer algebra system, just with a help of some shell script.
Update: For example, GAP could read this (some preliminary setup would be needed to define list f:=[]; and all inderteminates):
f[1]:=[
x2−x4−1,
x2+x1+1,
x3+1,
];

f[2]:=[
−x2−x3−1,
x2+x4+1,
x3*x2−x4,
x2−x1−1,
x3+x1−1,
];

Line breaks and empty lines does not matter, as well as commas after the last element of the list.
