# solving a system of polynomial functions with arbitrary length

I am trying to solve a system of polynomial functions:

$$x^T T_1 X = x_1 , \\ x^T T_2 x = x_2,\\ \vdots\\x^T T_l x =x_l$$

where $\{T_i\}$ is a given set of $l \times l$ matrices And I require a solution for vector $x=[x_1,\ldots x_l$]

The following code works nicely, for a given size $l=3$

S = Solve[{x.T[[1]][[1]].x == x1, x.T[[1]][[2]].x == x2,x.T[[1]][[3]].x == x3}, x]


The varible $T$ is a tensor which includes the set of matrices $T_1,\ldots,T_l$ along its third dimension.

The problem is - what can I do if the size of the input variables and the number of equations are unknown in advance? Is there a way to create an input expression to the Solve function with some kind of a for loop?

Ariel

• Under some assumptions your problem has analytic solution: if all matrices $T_i$ commute they are simultaneously diagonalizable. After such transformation ($T_i'=P T_i P^{-1}$, $x'=P x$) you can a set of linear equations for $y=x'^2$ that can be solved by standard methods. – yarchik Sep 7 '16 at 9:50
• In Mathematica, you don't need a for-loop. Use functions (Table) instead. – user202729 Sep 7 '16 at 10:29
• Thanks for the comment, however, I don't want to limit myself for a specific case. – Ariel Sep 7 '16 at 10:52
• are you simplybasking how to construct that Solve expression for arbitrary l ? – george2079 Sep 7 '16 at 11:36
• can you provide an example T to demonstrate your example working? – george2079 Sep 7 '16 at 13:55

I'd suggest to write the system as follows. Suppose that you have l matrices of dimensions {d, d}. Then your array T will have dimensions {l, d, d}. The list X of unknowns will have length d, and the list H of homogeneous terms will have length l. For example:

l = 3;
d = 3;

T = RandomInteger[10, {l, d, d}];
H = RandomInteger[10, l];
X = Array[x, d];


Then you can write and solve the system as

Solve[ T.X.X == H, X ]