Question: How to build a system of linear equations from a list of polynomials?

Hello

I need to build a system of linear equations from a list of polynomials.  The list of indeterminates is as follows:

incog:=[theta[1, 1], theta[1, 2], theta[2, 1], theta[2, 2], theta[2, 6], theta[3, 0], theta[3, 3], theta[3, 4], theta[3, 5]];

The list of polynomials is:

eq:=[1, theta[1, 1]+theta[2, 2]+theta[3, 3], -theta[1, 1]-theta[2, 2], theta[2, 6]*theta[3, 5], -theta[1, 1]*theta[3, 3]-theta[2, 2]*theta[3, 3], -theta[1, 1]*theta[2, 6]*theta[3, 5]+theta[1, 2]*theta[2, 6]*theta[3, 4], theta[1, 1]*theta[2, 2]*theta[3, 3]-theta[1, 2]*theta[2, 1]*theta[3, 3]+theta[1, 2]*theta[2, 6]*theta[3, 0]];

eq[1], eq[2] and eq[5] will be used as examples, although all of them should be used.  

In eq[1], there are no indeterminates, therefore the first line of the matrix related to the system of equations is:

[0, 0, 0, 0, 0, 0, 0, 0, 0]

In eq[2], there is a summation of  three indeterminates and the outcome is a set of three lines (summation of indeterminates)

[1, 0, 0, 0, 0, 0, 0, 0, 0]

[0, 0, 0, 1, 0, 0, 0, 0, 0]

[0, 0, 0, 0, 0, 0, 1, 0, 0]

In eq[5], there is a summation of a product of indeterminates and outcome is a set of two lines as follows:

[1, 0, 0, 0, 0, 0, 1, 0, 0]

[0, 0, 0, 1, 0, 0, 1, 0, 0]

 

Carrying on like this will result in a matrix of 14 lines with zeros and ones in positions related to the indeterminates.  Building the matrix is what matters to me.

I have a thousand of such problems with different indeterminates and set of polynomials.  

Any ideas on how to build a function to automatically create the matrices would be most appreciated.

Thank you.

Cheers

Ed

 

Please Wait...