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
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:
Remark: one can always add more indeterminates later, e.g.
(as you could see, numbers of indeterminates need not to be consecutive)
2) Get a list of indeterminates
to be able to address them by their position in the list
x, for example3) If you really need to parse the text where indeterminates are given using
x_inotation, you could assign them programmatically, for example:Now the following works:
4) Finally, after previous steps, I have created all the necessary setup to be able to reproduce three polynomials from your example:
5) The following function will calculate so called "external representation of a polynomial" as a list of the form
[mon,coeff,mon,coeff,...]wheremonis a monomial in expanded form (that is given as list) andcoeffis its coefficient:I will just paste this code into GAP:
6) Now I am able to use it as intended:
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 ofx_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):Line breaks and empty lines does not matter, as well as commas after the last element of the list.