ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 20 Mar 2018 23:22:34 +0100Evaluating a list of multivariate equations at random values.https://ask.sagemath.org/question/41662/evaluating-a-list-of-multivariate-equations-at-random-values/I have a list of multivariate equations, there are `o` multivariate equations in the list where `o` is an integer and `v = 2o`, the variables that make up the equations are the generators of `P = PolynomialRing(K,'x',n)` where `n = v + o` so for example if `o = 2` then `v = 4` and `n = 6` so the variables that make up the multivariate equations in the list would be `P.gens() = (x0, x1, x2, x3, x4, x5)`. Now i need to substitute in random values from `GF(q)` for the first `v` variables in each of the multivariate equations in the list so in the example above where `v = 4` random values from `GF(q)`would be substituted in for the variables `x0, x1, x2, x3`in each of the multivariate equations in the list, leaving equations in only two variables `x4 and x5`. I have tried to implement this but i don't really know where to start as i know i am doing something wrong but what i have is the following. If the list of multivariate equations is called `eqn` for example.
for i in range(v):
xi = var('x'+str(i))
eqnsub0 = eqn[i].subs({x[i]:GF(q).random_element()})
I already know this is very wrong as the indexing will already go out of bounds since `v > o` but i don't really know where to start with this. Any help would be great, thanks. Tue, 20 Mar 2018 22:51:34 +0100https://ask.sagemath.org/question/41662/evaluating-a-list-of-multivariate-equations-at-random-values/Comment by nbruin for <p>I have a list of multivariate equations, there are <code>o</code> multivariate equations in the list where <code>o</code> is an integer and <code>v = 2o</code>, the variables that make up the equations are the generators of <code>P = PolynomialRing(K,'x',n)</code> where <code>n = v + o</code> so for example if <code>o = 2</code> then <code>v = 4</code> and <code>n = 6</code> so the variables that make up the multivariate equations in the list would be <code>P.gens() = (x0, x1, x2, x3, x4, x5)</code>. Now i need to substitute in random values from <code>GF(q)</code> for the first <code>v</code> variables in each of the multivariate equations in the list so in the example above where <code>v = 4</code> random values from <code>GF(q)</code>would be substituted in for the variables <code>x0, x1, x2, x3</code>in each of the multivariate equations in the list, leaving equations in only two variables <code>x4 and x5</code>. I have tried to implement this but i don't really know where to start as i know i am doing something wrong but what i have is the following. If the list of multivariate equations is called <code>eqn</code> for example.</p>
<pre><code>for i in range(v):
xi = var('x'+str(i))
eqnsub0 = eqn[i].subs({x[i]:GF(q).random_element()})
</code></pre>
<p>I already know this is very wrong as the indexing will already go out of bounds since <code>v > o</code> but i don't really know where to start with this. Any help would be great, thanks. </p>
https://ask.sagemath.org/question/41662/evaluating-a-list-of-multivariate-equations-at-random-values/?comment=41663#post-id-41663see https://ask.sagemath.org/question/41655Tue, 20 Mar 2018 23:22:34 +0100https://ask.sagemath.org/question/41662/evaluating-a-list-of-multivariate-equations-at-random-values/?comment=41663#post-id-41663