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 15:44:10 +0100Creating a symbolic matrix in a loop and then substituting values in for the variables?https://ask.sagemath.org/question/41655/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.DalvirTue, 20 Mar 2018 15:44:10 +0100https://ask.sagemath.org/question/41655/How can I get Sage to go over all possible maps between two sets?https://ask.sagemath.org/question/26705/how-can-i-get-sage-to-go-over-all-possible-maps-between-two-sets/ What I want to do is this : Say I take a graph $K_{n,n}$ and choose an ordering for each edge arbitrarily - say denote each edge as $(i,j)$ where $i$ is in the left partition and $j$ is in the right partition. I have a set of matrices $A = { A_1, A_2,...,A_k \}$. I want to iterate over all possible ways in which one could have assigned an A matrix to an edge of this graph.
- How does one do that? (..apart from writing a massive sequence of nested loops!..)
phoenixSun, 03 May 2015 00:25:28 +0200https://ask.sagemath.org/question/26705/looping newlinehttps://ask.sagemath.org/question/9343/looping-newline/I am running Sage 5.1 under Windows 7 using the Virtual Box image.
When I enter a gp program with a newline it goes into a loop.
This works:
%gp
lucas(p) ={my(u,q); u=4; q=1<<p - 1;for(k=3,p, u = (sqr(u)-2) % q);u == 0;}
lucas(5)
But this does not:
%gp
lucas(p) ={
my(u,q);
u=4;
q=1<<p - 1;
for(k=3,p, u = (sqr(u)-2) % q);
u == 0;
}
lucas(5)
Can you tell me what I need to do so that I can enter a program on multiple lines?
BrianSat, 22 Sep 2012 20:57:59 +0200https://ask.sagemath.org/question/9343/