Creating a symbolic matrix in a loop and then substituting values in for the variables?
I need to create a symbolic matrix in terms of the variables xi with one row of n elements for a given integer n, so for example if n=5 i would need to compute the matrix [x0, x1, x2, x3, x4]
As a follow on from this i then need to substitute in random values from a finite field say GF(q)
for the first v
number of variables in the matrix for a given integer v < n
. So for example if v = 3
then i would need to substitute in random values from GF(q)
for the first x0, x1, x2
variables of the matrix to get something like [GF(q).random_element(), GF(q).random_element(), GF(q).random_element(), x3, x4 ]
of course i need to be able to do this for any integers n and v i choose. Any help about how to do this in sage would be great, thanks.
EDIT: I need to substitute in random values from a finite field say GF(q)
for the first v
number of variables for a given integer v < n
into each of the multivariate equations in a list. So for example, if my list of multivariate equations is given by eqn
where eqn
looks like the following: [[10*x0^2 + 11*x0*x1 - 12*x1^2 - 14*x0*x2 + 8*x1*x2 + 6*x2^2 - 15*x0*x3 - 13*x1*x3 - 7*x2*x3 + 9*x3^2 - 13*x0*x4 + 11*x1*x4 + 6*x2*x4 - 15*x3*x4 + 11*x4^2 - 13*x0*x5 + 12*x1*x5 + 6*x2*x5 - 8*x4*x5 + x5^2], [4*x0^2 + 8*x0*x1 - 3*x1^2 - 8*x0*x2 - 3*x1*x2 - 10*x2^2 + 5*x0*x3 - 14*x1*x3 - 5*x2*x3 - 12*x3^2 - 10*x0*x4 + 8*x1*x4 - 10*x2*x4 - 4*x3*x4 + 6*x4^2 - 11*x0*x5 - 3*x1*x5 - 9*x2*x5 + 9*x3*x5 + 4*x4*x5 - 11*x5^2]]
when o = 2
then i need to substitute random values from GF(q) into the first v variables, to obtain a list of multivariate equations in only the remaining variables that have not been substituted.
In the definition of
eqn
, why do you have[[f], [g]]
instead of[f, g]
?